473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2234
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
6
by: | last post by:
I am rewriting a C++ application in C#. This file has a combination of Text and Binary data. I used CFile before to read the text. If I hit a certain string that denotes the following data is...
20
by: ishmael4 | last post by:
hello everyone! i have a problem with reading from binary file. i was googling and searching, but i just cant understand, why isnt this code working. i could use any help. here's the source code:...
2
by: RP2001 | last post by:
I've serialized in various variables of various types (mainly CString, int, double) into an instantiated MFC CArchive class and saved it as a binary file. I am able to open the binary file and...
3
by: John R. Delaney | last post by:
I am running in debugging mode after a clean C++ compilation under .NET 2003. In a BIG loop (controlled many levels up in the call stack), I open a file with fopen using the "a" option. Then I write...
12
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands. the surprising thing is that the program works...
4
by: Matrixinline | last post by:
Hi All Here is my problem I am using a Unicode project and I tried to read the File like sPath = LPCTSTR; FILE* oFp = _tfopen(sPath,L"r"); while(!feof(oFp))
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
5
by: Neil Crighton | last post by:
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.