I am trying to read a binary file with the BinaryReader class, and I need to read it as UInt32 blocks, and then do some bit shifts, etc. afterwords.
But for some reason, the order of the bits is canceled when I use the ReadUInt32 method.
If, for example, I have a file in which the first four bytes look like hexadecimal, 0x12345678 , they end as ReadUInt32 read: 0x78563412 .
If I use the ReadBytes (4) method, I get the expected array:
[0x00000000] 0x12 byte [0x00000001] 0x34 byte [0x00000002] 0x56 byte [0x00000003] 0x78 byte
Why is this? Is this just the way .net represents uints in memory? Is it the same thing on different platforms (am I running 64-bit Windows 7, .net 3.5 sp1)?
Egil hansen
source share