using System; using System.IO;class FSRead { public static void Main() { //Create a file stream from an existing file. FileInfo fi=new FileInfo("c:\\csc.txt"); FileStream fs=fi.OpenRead(); //Read 100 bytes into an array from the specified file. int nBytes=100; byte[] ByteArray=new byte[nBytes]; int nBytesRead=fs.Read(ByteArray, 0, nBytes); Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString()); } }
using System;
using System.IO;class FSRead
{
public static void Main()
{
//Create a file stream from an existing file.
FileInfo fi=new FileInfo("c:\\csc.txt");
FileStream fs=fi.OpenRead(); //Read 100 bytes into an array from the specified file.
int nBytes=100;
byte[] ByteArray=new byte[nBytes];
int nBytesRead=fs.Read(ByteArray, 0, nBytes);
Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString());
}
}
????