Help: how to read binary file into an array?

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

Hi

Could someone kindly help with the C# equivilent of the following 4 lines
of C code. I'm *really* struggling with this.
( Colours.dat contains 300 RGB values )



COLORREF Colours[300];

int iHnd = open("colours.dat", O_RDONLY | O_BINARY);
read(iHnd, (char*)&Colours, sizeof(Colours));
close(iHnd);



Thanks in advance
Pete
 
Not coding here but the general way to do it is

1. Open a File stream
2. Use the System.IO.BinaryReader to read the file
3. Use the System.Drawing.Color to decode the binary you've read

HTH
Hi

Could someone kindly help with the C# equivilent of the following 4 lines
of C code. I'm *really* struggling with this.
( Colours.dat contains 300 RGB values )



COLORREF Colours[300];

int iHnd = open("colours.dat", O_RDONLY | O_BINARY);
read(iHnd, (char*)&Colours, sizeof(Colours));
close(iHnd);



Thanks in advance
Pete
 
Back
Top