Skip to content

Instantly share code, notes, and snippets.

@phucnguyenv
Last active August 29, 2015 14:27
Show Gist options
  • Save phucnguyenv/03538b6ac601c4c77c59 to your computer and use it in GitHub Desktop.
Save phucnguyenv/03538b6ac601c4c77c59 to your computer and use it in GitHub Desktop.
C#: Read a file into byte array
// Read a file into byte array
internal static byte[] ReadFile (string fileName)
{
FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read);
int size = (int)f.Length;
var data = new byte[size];
size = f.Read(data, 0, size);
f.Close();
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment