How to read all bytes of a file

4

I have a question in ReadBytes (int)

My code looks like this:

BinaryReader r = new BinaryReader (File.OpenRead(ARQUIVO));

byte[] arraybyte = r.ReadBytes(100000);

This 100000 that I put is because I do not know the size of the file, how can I simply make it read all the bytes of the file?

    
asked by anonymous 20.05.2015 / 17:33

1 answer

4

You can use File.ReadAllBytes(string) for what you want:

byte[] todosOsBytes = File.ReadAllBytes(ARQUIVO);
    
20.05.2015 / 17:41