Hello.
I am reading in a file as a stream through a binaryreader. I read in a number of bytes but when checking the basestream position its a lot further a long than it should be.
Code example:
- public void MainLoader()
- {
- FileStream input = System.IO.File.Open(path, System.IO.FileMode.Open);
- BinaryReader binaryReader = new BinaryReader(input, Encoding.GetEncoding(1252));
- byte[] bytes = binaryReader.ReadBytes(256);
- binaryReader.ReadInt32();
- binaryReader.ReadInt32();
- binaryReader.ReadInt16();
- binaryReader.ReadInt32();
- binaryReader.ReadInt16();
- binaryReader.ReadByte();
- binaryReader.ReadBoolean();
- binaryReader.ReadByte();
- binaryReader.ReadByte();
- binaryReader.ReadInt16();
- binaryReader.ReadByte();
- binaryReader.ReadBoolean();
- binaryReader.ReadByte();
- binaryReader.ReadByte();
- binaryReader.ReadByte();
- binaryReader.ReadInt16();
- binaryReader.ReadInt16();
- binaryReader.ReadByte();
-
- binaryReader.ReadByte();
- binaryReader.ReadByte();
- binaryReader.ReadByte();
- binaryReader.ReadByte();
-
- var position = binaryReader.BaseStream.Position
- binaryReader.Close();
- }
Adding up all the read in bytes should be 292, and this should be the stream position too ( I read from the start of the file)
The issue I have is that in fact it returns 4096. I do not understand this, what could be influences this.
I have thought maybe Culture settings, Encoding, or Endians, but I am no sure.
Any thoughts would be great.