Has anyone had any luck with binary file I/O?
I'm used to the good ole VB syntax...You know create a few structs for the headers and an array for the data. Then, read them in...It's like 6 lines (including the open and close).
Actually this is about the same in C++. So, why is this so dang obscure in C#? Or am I just slow (this is altogether possible).
I would like find an intelligent to read and write binary data (read not serialization) that is "Safe" in the .net sense. The biggest problem I've come accross so far is trying to read in a structure with what should be a fixed string:
I've tried to explicitly define the structure, and to use pointers ( which work fine for fixed structure sizes ) but it just doesn't seem easy. And I haven't found a "Safe" way to do it yet....PHP Code:struct MakeBelieveStructure
{
public string MyName; // should be 20 characters
public string MyAddress; // should be 100 characters
public int[] MyNumbers; // List of 20 integers
}
// What I would like to do...
BinaryReader MyReader = new BinaryReader();
MakeBelieveStructure MyStruct;
MyStruct = MyReader.Read(sizeof(MakeBelieveStructure));
any ideas?![]()
![]()




Reply With Quote