Reading "null"s from binary file C# -


i wrote small function reads binary file byte array. there 1 bin file when i'm reading it, gives me "null"s (if char[]) or zeros (if byte[]), see when i'm in debug mode. thing when i'm using in same function read bin file works fantastic!

here 1 piece of code:

        filestream fs = new filestream(path, filemode.open, fileaccess.read);         binaryreader r = new binaryreader(fs);         (int = 0; < 500; i++)         {             data[i] = r.readbyte();         } 

here function i'm using:

        byte[] filebytes = file.readallbytes(path);         stringbuilder sb = new stringbuilder();          foreach (byte b in filebytes)         {             sb.append(convert.tostring(b, 2).padleft(8, '0'));         }          file.writealltext(outputfilename, sb.tostring()); 

clarification - binary file i'm trying read not empty , contains strings (seen when i'm opening file editing tools).

also, these pisces of codes reads other binary files.

what can problem? there differences between 1 binary file another?


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -