Question

I have a binary file, that was written in C, which contains a long stream of numbers. First it contains subsequently 4 times an int (so the first 16 bytes are 4 ints) and then it contains doubles (I assume every 8 bytes a new double).

There are no spaces at any point or anything else. Now I need to read the data with C# but so far everything I tried simply didn't work, any suggestions?

Was it helpful?

Solution

using (BinaryReader br = new BinaryReader(File.Open("file", FileMode.Open)))
{
  int a = br.ReadInt32();
  int b = br.ReadInt32();
  int c = br.ReadInt32();
  int d = br.ReadInt32();
  double e = br.ReadDouble();
  double f = br.ReadDouble();
  ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top