Reading of file gets cut off near the end.

  • Thread starter Thread starter Rvo
  • Start date Start date
R

Rvo

Hi all,

I have a routine that reads a binary file into a string, this worked fine
all the time, untill recently. Now the reading of the file seems to reach
the end of file too soon. At the end the file is cut off.

I have no clue what is going wrong here.

Below is the code snippet which I use to read the data. I had to make alle
lines comment because our firewall is kinda paranoid.

Thanks for your time.

Romain.



'toRead = FreeFile()

'binFile = ""

'ChDir(PathToUse)

'Microsoft.VisualBasic.FileOpen(toRead, myFilename, OpenMode.Binary,
OpenAccess.ReadWrite, OpenShare.LockReadWrite)

'While Not (EOF(teLezen))

' aLine = Microsoft.VisualBasic.FileSystem.LineInput(teLezen)

' binFile = binFile + aLine & vbCr

'End While

'Microsoft.VisualBasic.FileClose(toRead)
 
I have a routine that reads a binary file into a string, this worked fine
all the time, untill recently. Now the reading of the file seems to reach
the end of file too soon. At the end the file is cut off.

Search this file with a hex editor and see if you find ASCII character 26.
This is an end-of-file marker.

I highly recommend AGAINST using text-based functions like Line Input to
read binary data.
Below is the code snippet which I use to read the data. I had to make alle
lines comment because our firewall is kinda paranoid.

Your firewall understands Basic? Wow.
 
Hi Jeff,

I didn't find any ascii value 26 in the file and the file is a just a long
text string.

When I put the last few lines together onto one longer line the file wil
read completely.


Regards,

Romain

PS: Our firewall is aware of possibly dangerous code (e.g. vbscript and the
likes). It's a pain :-)
 
I didn't find any ascii value 26 in the file and the file is a just a long
text string.

When I put the last few lines together onto one longer line the file wil
read completely.

Why not go the .NET route and open a StreamReader against the file?
 
Dear JEff,

I just did that and it works just fine. Thanks for your help.

Kind regards,

Romain
 
Back
Top