Solved

Readall method not reading ntbackup log files

Posted on 2006-07-12
2
260 Views
Last Modified: 2012-06-21
I am having a problem with reading in a txt file using Readall method. When it read in a file it returns only ÿþB characters. This only does it on log file created by ntbackup, if I create a simple text file it works fine. I also can copy the text out of the log file and past into an other file and it is fine.

Not sure it there is something in the formatting of this log file that kills the readall method.

This is the code that I am using. Any ideas why this is happening?

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("c:\backup01.log", ForReading)
'The ReadAll method reads the entire file into the variable BodyText
BodyText = f.ReadAll
MyVar = MsgBox (BodyText, 65, "MsgBox BodyText")
'Close the file
f.Close
Set f = Nothing
Set fso = Nothing
0
Comment
Question by:pointhigh
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 125 total points
ID: 17091210
Hi pointhigh,

Because readall stops if it encounters an end-of-file marker such as 0x26 or even 0x0 null characters. You have to do it byte by byte or use a different method that allows you to read binary files rather then text files (which is what the FSO was designed for).

Tim Cottee
0
 

Author Comment

by:pointhigh
ID: 17091300
Ok that makes sense, when I rename the file to backup01.txt it gets the same characters, but when I the text out in notepad and past into a new file it is fine.
Thanks for the very fast answer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now