G
Guest
I use BinaryReader to read my binary dafa files, when i call ReadBytes, why
it always return more 4 bytes. The following is my code.
FileStream fs = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes(8);
bytes = br.ReadBytes(1);
After the first sentence, fs.Position is 0, and all things is ok, but when
runs to the second sentence, i found fs.Position is 4, when runs to the third
sentence, i got the wrong data, and fs.Position is 16, after the fourth
sentence, fs.Position is 21.
I try to reset fs.Position to 0 before the construct br, but failed.
Thanks.
it always return more 4 bytes. The following is my code.
FileStream fs = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes(8);
bytes = br.ReadBytes(1);
After the first sentence, fs.Position is 0, and all things is ok, but when
runs to the second sentence, i found fs.Position is 4, when runs to the third
sentence, i got the wrong data, and fs.Position is 16, after the fourth
sentence, fs.Position is 21.
I try to reset fs.Position to 0 before the construct br, but failed.
Thanks.