Read hex in C# using IO
Don't use a StreamReader
—that's only for characters in a certain encoding (default UTF8). Use a FileStream
class instead:
FileStream fs = new FileStream(fileDirectory, FileMode.Open);
int hexIn;
String hex;
for (int i = 0; (hexIn = fs.ReadByte()) != -1; i++){
hex = string.Format("{0:X2}", hexIn);
}