Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Readall method not reading ntbackup log files

Posted on 2006-07-12
2
Medium Priority
?
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

721 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