Given a file and we have to read it’s all bytes (byte buffer) using C# program.
File.ReadAllBytes()
This is a method of "File class, it is used to read all bytes from the given file.
Syntax:
Byte[] ReadAllBytes(string filename);
Parameter(s):
- filename - name of the file.
Return value:
This method return array of bytes, in which every element of array contains a byte.
Program
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.