I'm having trouble converting a byte array to a string. I've looked up and tried several examples on how this is supposed to work, and none of them seem to be working.
I have a program called UltraEdit, which allows me to read the characters of my binary file.
The first line (first 16 bytes) of my file is:
05 59 1D 59 CD 08 05 C1 1C 0C 0C 08 F1 9D 59 B9
When I step through the program, I can see that the file is being read in correctly, as the byte array "binData" holds the correct values.
However, the data is NOT being converted correctly when I use the string conversion methods shown in the code snipet below:
string sData = Encoding.GetEncoding(1252)
(binData) is producing:
05 59 1D 59 CD 5C 62 05 C1 1C 5C 66 5C 66 5C 62
string sData = Endocing.ASCII.GetString(b
inData) is producing:
05 59 1D 59 3F 5C 62 05 3F 1C 5C 66 5C 66 5C 62
string binFile = "C:\\Documents and Settings\\User\\Desktop\\TestBin.bin";
byte binData = File.ReadAllBytes(binFile);
// Ways I have tried:
string sData = Encoding.GetEncoding(1252).GetString(binData);
string sData = Endocing.ASCII.GetString(binData);