Created
May 13, 2014 19:16
-
-
Save jglozano/6ff59c03842e57f181fb to your computer and use it in GitHub Desktop.
Reflector inferred impl of InternalReadAllBytes
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
[SecurityCritical] | |
private static byte[] InternalReadAllBytes(string path, bool checkHost) | |
{ | |
byte[] buffer; | |
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.None, Path.GetFileName(path), false, false, checkHost)) | |
{ | |
int offset = 0; | |
long length = stream.Length; | |
if (length > 0x7fffffffL) | |
{ | |
throw new IOException(Environment.GetResourceString("IO.IO_FileTooLong2GB")); | |
} | |
int count = (int) length; | |
buffer = new byte[count]; | |
while (count > 0) | |
{ | |
int num4 = stream.Read(buffer, offset, count); | |
if (num4 == 0) | |
{ | |
__Error.EndOfFile(); | |
} | |
offset += num4; | |
count -= num4; | |
} | |
} | |
return buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment