Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Reading File Summary Info via FSO 1

Status
Not open for further replies.

JHerr

Programmer
May 25, 2001
42
0
0
US
OK, here's my deal. I have Crystal reports on various pc's on the network and they all must be the same version. so to check this, I want to grab the revision number of off the summary info of the file (right click> properties> file summary information> advanced> revision).

Well, I haven't seen anyone who can tell me how to do that with any straight forward method in vb6, so I found the place its kept in the file header, and I want to read in the file line by line and parse for what I need. Seems simple right? Not exactly.

It seems windows knows the summary info file header when it sees it because I can find what I need easily in notepad but as soon as I use file system object to readline the file in all the info I need is gone. As a matter of fact a readall of the file shows it to be completely different that what shows in notepad, but that’s more of an aside than the actual dilemma. So then I decided that perhaps it was a crystal reports issue and that renaming the file with a different extension might make a difference. Wrong. I’ve tried a bunch already, just anything I could think of to try and throw it off but no matter what I do the file gets converted during the reading and my summary info is gone. I realize if you read this far you must be exhausted but I’ve had this issue now for a while and I’m just dumbfounded. If anyone can offer any help/insight/solutions to this I’d be extremely grateful. Thank you so much
-Jacob Herrera

Just in case you’re wondering, here's what I’m using. its pretty straight forward:

Code:
  Dim cFSO As New FileSystemObject
  Dim cF As file
  Dim line as string

  Set cF = cFSO.GetFile(filename)
  Set cStream = cF.OpenAsTextStream(ForReading)
  line = cStream.ReadLine
 
Have you tried the native Open/Input statements in VB?

Open &quot;c:\myfile.exe&quot; For Binary Access Read As #<filenumber>

Input(<# of chars>, #<filenumber>)

Good luck,
RS
 
Thanks vb5prgrmr & 173234 !!
i used vb5prgrmr's suggestion and its perfect now. your my hero. thanks to both of you for your quick responses!!
-JH
 
...try using Open statement to open the file as binary for read only access. and if you know the byte position of the value that you're looking for, then try using Seek function to help return the value faster... something like this:

Dim TextChar

Open &quot;c:\temp\FILE.rpt&quot; For Binary Access Read As #1 ' open file.
Seek #1, 29 'byte position at 29
TextChar = Input(1, #1) ' get one character.
Debug.Print TextChar

Close #1 ' Close file.

...by the way, you can get the byte position of a value by looping through the record:

Do While Not EOF(1)
myChar = Input(1, #1)
Debug.Print myChar 'print character of data
Debug.Print Seek(1) 'print byte position
Loop

...Have Fun!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top