Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Readall method not reading ntbackup log files

Posted on 2006-07-12
2
Medium Priority
?
331 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 500 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

885 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