Created
June 24, 2017 22:36
-
-
Save mlschneid/29399dde82c3afa3e165093fe8be2b67 to your computer and use it in GitHub Desktop.
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
static async Task<byte[]> ReadBytesAsync(string filePath) | |
{ | |
byte[] buffer; | |
using(FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) | |
{ | |
buffer = new byte[fs.Length]; | |
if (fs.Length < Int32.MaxValue) | |
{ | |
await fs.ReadAsync(buffer, 0, (int)fs.Length); | |
} | |
else | |
{ | |
throw new Exception("File too large for this method"); | |
} | |
} | |
return buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment