Solved

Readall method not reading ntbackup log files

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

856 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