Search This Blog

Thursday, January 15, 2015

ReadAllBytes C# Example

C# > Files > File Class > ReadAllBytes

Opens, reads the contents of the file into a byte array, and then closes the file.

Example

Read bytes from jpg file and display to PictureBox.

var bytes = File.ReadAllBytes("D:\\Pics\\1.jpg");
pictureBox1.Image = Image.FromStream(new System.IO.MemoryStream(bytes));