Read, Write & Conversion Bytes

byte[] file = File.ReadAllBytes("path");
string sb = BitConverter.ToString(file); \* Output: 1A-2F-C3

/* Write */
string[] hex = sb.Split('-');
byte[] raw = new byte[hex.Length];
for (int i=0; i<raw.Length; i++)
raw[i] = Convert.ToByte(hex[i], 16);

File.WriteAllBytes("path", raw);

0 comments: