Solved

Readall method not reading ntbackup log files

Posted on 2006-07-12
2
281 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

816 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

13 Experts available now in Live!

Get 1:1 Help Now