I'm creating a binary file using the binarywriter class. I'm writing decimal numbers to the file, each one as a 4 byte representation.
So, if I wanted to write the decimal number 10523
The hex would be 0x291B.
I need the bytes written to the file in this order:
0x1B 0x29 0x00 0x00
My problem is that using this code:
The bytes are written to the file in this order:Code:byte[] numBuffer = null; decvalue = 10523; numBuffer = System.Text.Encoding.ASCII.GetBytes(decvalue.ToString("x4")); wrtBin.Write(numBuffer);
0x29 0x1b 0x00 0x00
What's the best way for me to do this?




Reply With Quote