Reading binary file

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Can someone tell me the best way to read fixed length string content from a
binary file. There are no delimiters between strings. I only know the
starting byte and that each string is 64 Bytes long. I was doing something
like the following but it seems as though I must be doing this the hard way?

Thanks in advance for your help.

Dave

BinaryReader *binaryInput;

FileStream *fileInput;

__wchar_t tHold;

String *testing;

fileInput = new FileStream( filename, FileMode::Open, FileAccess::Read );

binaryInput = new BinaryReader( fileInput );

// find beginning of comment data

fileInput->Seek( AppData->CommentStartByte , SeekOrigin::Begin );

for ( int i=1; i <= AppData->CommentByteLen; i++ ){

tHold = binaryInput->ReadChar();

testing = String::Concat( testing, tHold.ToString() );

}
 
Sorry, The AppData is just a udt to hold all of the information required to
find data in thes files. Also, the files are data files from an old program
I developed in another language long ago. Now I need to read these files
and convert them to a different structure for a new version of the same
program to be written in MS VC++.NET.

Thanks again for the help.

Dave
 
Back
Top