File.ReadAllBytes(String)
File.ReadAllBytes(String)
File.ReadAllBytes(String)
File.ReadAllBytes(String)
Method
Definition
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
public:
static cli::array <System::Byte> ^ ReadAllBytes(System::String ^ path);
public static byte[] ReadAllBytes (string path);
static member ReadAllBytes : string -> byte[]
Public Shared Function ReadAllBytes (path As String) As Byte()
Parameters
Returns
A byte array containing the contents of the file.
Exceptions
path
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
path
is null
.
The specified path, file name, or both exceed the system-defined maximum length.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
This operation is not supported on the current platform.
-or-
path
specified a directory.
-or-
The caller does not have the required permission.
The file specified in path
was not found.
path
is in an invalid format.
The caller does not have the required permission.
Remarks
Given a file path, this method opens the file, reads the contents of the file into a byte array, and then closes the file.
Security
FileIOPermission
for access to read from a file or directory. Associated enumeration: Read
Applies to
See also
Feedback
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.
Loading feedback...