That struct declaration is off, sorry. I did not proof it as well as I should have. You would need:
struct FlightData_str
{
byte[,] dataCell = new byte[11, 200];
byte[,] breakoutOrig = new byte[10, 10];
byte[,] breakoutConn = new byte[10, 10];
};
Main Topics
Browse All Topics





by: EgorePosted on 2006-03-01 at 10:58:11ID: 16077909
This is not tested, but I'm pretty sure you can set up your first struct like this:
str) bytes at a time (using StreamReader or something similar) and then use the CopyMemory API call to copy the block of memory that you read into the structure. This code probably won't compile, but it demonstrates what you're trying to do:
str); ) {
struct FlightData_str
{
byte dataCell[11][200];
byte breakoutOrig[10][10];
byte breakoutConn[10][10];
};
Then you can read in Marshal.SizeOf(FlightData_
int size = Marshal.SizeOf(FlightData_
byte[] block = new byte[size];
using(StreamReader r = new StreamReader("myfile.txt")
while(r.Peek() > 0) {
r.Read(block, 0, size);
FlightData_str fd = new FlighData_str();
CopyMemory(fd, block, size);
/* Use fd here */
}
}
You may need to use the StructLayout attribute on the FlightData_str structure, but it appears that it defaults to "sequential", so it probably is not needed. If you need more fleshed-out code, just let me know. I hope this helps point you in the right direction.