public Read ( byte array, int offset, int count ) : int | ||
array | byte | |
offset | int | |
count | int | |
return | int |
using System; using System.IO; class Program { static void Main() { FileStream fs = new FileStream("example.txt", FileMode.Open, FileAccess.Read); byte[] buffer = new byte[100]; int bytesRead = fs.Read(buffer, 0, 100); Console.WriteLine("Read {0} bytes.", bytesRead); fs.Close(); } }
using System; using System.IO; class Program { static void Main() { FileStream fs = new FileStream("example.txt", FileMode.Open, FileAccess.Read); byte[] buffer = new byte[fs.Length]; int bytesRead = fs.Read(buffer, 0, (int)fs.Length); Console.WriteLine("Read {0} bytes.", bytesRead); fs.Close(); } }In both examples, the package used is System.IO.