Skip to content

How To Read All The Bytes From A File in C# and Put Them Into A Byte Array

Updated: at 11:18 PM

I normally don’t blog about such simple things, but somehow, I’ve always done this in about 5 lines of code and I ran into at eggheadcafe in one line this morning.  Simply using the File static method ReadAllBytes of the File class.

Here it is.  Can’t be much simpler I don’t think.


byte[] downloadByteArray = File.ReadAllBytes(imageLocation);

That’s it! hope this helps someone else.