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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading strings from binary file fails

Status
Not open for further replies.

mromill

Technical User
Oct 11, 2003
7
NL
Hi all,

I have a binary (database)file. The structure is simpel:
4x string with fixed length and containing general info
1x long value indicating nr of parameters
1x long value indicating nr of locations
a list with strings with the parameternames
a list with strings with the locationnames
then all data for each parameter/location/timestep

in VB6 with the Get-statement it reads a record and i don't have to specify the number of characters to be read. In VB.Net (2005beta) i tried this:

Dim BR As New IO.BinaryReader(IO.File.OpenRead(sPath & "\" & sfilename))

reading header, nr of locations, parameters and redim array's
so far, this works fine

...
For i = 0 To lNrOfParameters
asParameters(i) = BR.ReadString
Next i
...

This is where my code 'fails', the strings are not correct, ReadString seems to have a fixed length and i don't know the length of each parameter-string. How can i solve this?

Best regards,

John
 
My guess would be that you'll need to read it firstly as an array of bytes, and then convert each sub-part of the array into your strings, etc.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top