M
Matt Laver
Hi,
I have a binary file that I'm currently reading byte by byte using code
similiar to:
string FileName = @"c:\myFile.dat";
FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
Header = r.ReadInt32(); //file header
Version = r.ReadInt32(); //file Version
FileSize = r.ReadInt32(); //file Size
....
Is there anyway that I could group some of these bytes into a structure
and read it in one go, e.g.:
public struct FirstStructure
{
public long header;
public long Version;
public long FileSize;
...
}
I've had a look at serialization, however have only found examples for
objects, not structures. I can not change the format of the file as it is
legacy and is written by comitting a series of records (delphi records)
to this file.
Anyone got any ideas or suggestions?
Thanks
I have a binary file that I'm currently reading byte by byte using code
similiar to:
string FileName = @"c:\myFile.dat";
FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
Header = r.ReadInt32(); //file header
Version = r.ReadInt32(); //file Version
FileSize = r.ReadInt32(); //file Size
....
Is there anyway that I could group some of these bytes into a structure
and read it in one go, e.g.:
public struct FirstStructure
{
public long header;
public long Version;
public long FileSize;
...
}
I've had a look at serialization, however have only found examples for
objects, not structures. I can not change the format of the file as it is
legacy and is written by comitting a series of records (delphi records)
to this file.
Anyone got any ideas or suggestions?
Thanks