|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
problem to read binary fileI 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
Show quote
Hide quote
"Quinn" <q***@yahoo.com> wrote in message Suggestion:news:us3n1cwuGHA.4444@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 > 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
Must call RemoveHandler after AddHandler?
IIS - Cannot create ActiveX component VS 2005 freezes during code editing (HotFix 917452) How to raise an event when a transaction is rollbacked .Net combo box - what is "opposite" of DropDown event? Excel to Visual Basic .NET Receive serial data Configuration file Simple SQL question Create a file hash |
|||||||||||||||||||||||