Last active
August 29, 2015 14:27
-
-
Save phucnguyenv/03538b6ac601c4c77c59 to your computer and use it in GitHub Desktop.
C#: Read a file into byte array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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