If I were reading byte numbers I would do:
using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
int size = (int) stream.Length;
BinaryReader br = new BinaryReader(stream);
byte[] test = new byte[size];
test = br.ReadBytes(size);
br.Close();
}
But since I want to read Uint16, I am struck doing:
using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
int size = (int) stream.Length;
BinaryReader br = new BinaryReader(stream);
float[] test = new byte[size/2];
for (int i = 0; i < size/2; ++i)
{
test[i] = br.ReadUInt16();
}
br.Close();
}
Is there a faster way to read the whole file at once or is the speed difference negligeable ?