469,898 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

problem to read binary file

Hi all,

I have some binary files in the following format:

text line 1
text line 2
....
text line N
end of text
single in binary 1 single in binary 2 single N EOF
what I want to do is, to read text line by line until reached "end of text",
the start read binary numbers.

I start with a binaryreader

br.readstring until regex.ismatch(br.readstring) is true, then start
readsingle.

the problem is, the binary files were generated from VB6 program, the
br.readstring length does not match the VB6 string length. so sometimes the
"end of text" cannot be found.
I also think I can use a stream read to read the text first, then use the
binaryreader to read the binary part. but I cannot find the location where
the binary started.

Please help.

Quinn
Aug 8 '06 #1
1 1849
"Quinn" <qj**@yahoo.comwrote in message
news:us**************@TK2MSFTNGP05.phx.gbl...
Hi all,

I have some binary files in the following format:

text line 1
text line 2
...
text line N
end of text
single in binary 1 single in binary 2 single N EOF
what I want to do is, to read text line by line until reached "end of
text", the start read binary numbers.

I start with a binaryreader

br.readstring until regex.ismatch(br.readstring) is true, then start
readsingle.

the problem is, the binary files were generated from VB6 program, the
br.readstring length does not match the VB6 string length. so sometimes
the "end of text" cannot be found.
I also think I can use a stream read to read the text first, then use the
binaryreader to read the binary part. but I cannot find the location where
the binary started.

Please help.

Quinn
Suggestion:

Read the file into a byte-array. Convert each byte in the array into a
string, one byte at a time and append to a string. If the string ends with
(EndsWith method) "end of text", then you have reached the start of the
binary data :)

HTH,
Mythran
Aug 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Brandon McCombs | last post: by
3 posts views Thread by John R. Delaney | last post: by
12 posts views Thread by Julian | last post: by
4 posts views Thread by Matrixinline | last post: by
6 posts views Thread by efrenba | last post: by
5 posts views Thread by Neil Crighton | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.