Hi, im a new programmer to C# and I just do not understand why my binary file is read incorrectly.
I have a 625 byte binary file and it only reads 586 bytes, skipping a byte once in a while.
The result is the same everytime.
Is there something im missing?
Any help would be truly appriciated.
//Returns the file data as a byte array
public static byte readfilebytes(string filex)
TextReader tr = new StreamReader(filex);
string collected = "";
while ((buffer = tr.ReadLine()) != null)
collected += buffer;
//625 byte binary file
//586 bytes in the variable collected
byte bytes = new byte[collected.Length];
int i = 0;
foreach (char c in collected.ToCharArray())
bytes[i] = (byte)c;