U
Usenet User
I am trying to read (and then save) a binary file which has certain
data structures in it. (The file is in propritetary format produced by
a 3rd party MFC application.)
I know that those data structures would correspond to the structures
similar to the one below:
[StructLayout(LayoutKind.Sequential)]
private struct MyStruct
{
Int64 Signature;
Int16 VersionNumber;
Int16 Key;
Int32 NodeID;
byte[] Signature2; <--- byte array of 24 bytes
Int64 ContentLength;
...
}
I implemented the structures in my C# code, but how would I read and
populate them from the file's content? I know I can parse the binary
stream explicitly using, for example, BinaryReader, but it means I
would have to read the stream field by field.
Is there an easier way?
As far as I remember, the above could be easily done in C/C++: one
would just printf/scanf data structures with no additional effort.
TIA!
data structures in it. (The file is in propritetary format produced by
a 3rd party MFC application.)
I know that those data structures would correspond to the structures
similar to the one below:
[StructLayout(LayoutKind.Sequential)]
private struct MyStruct
{
Int64 Signature;
Int16 VersionNumber;
Int16 Key;
Int32 NodeID;
byte[] Signature2; <--- byte array of 24 bytes
Int64 ContentLength;
...
}
I implemented the structures in my C# code, but how would I read and
populate them from the file's content? I know I can parse the binary
stream explicitly using, for example, BinaryReader, but it means I
would have to read the stream field by field.
Is there an easier way?
As far as I remember, the above could be easily done in C/C++: one
would just printf/scanf data structures with no additional effort.
TIA!