accessing a specific area in a file...?
How can i access a specific range of characters in file?
for example I want to open a text file and read from character #39 to character #99.
Is there a way of doing this without reading the whole file using the FileStream.ReadToEnd() Method, and then accessing the specific characters???
The ReadToEnd method could take a long time if it's a big file, and i only need a small portion of the file content...
Re: accessing a specific area in a file...?
Re: accessing a specific area in a file...?
Or:
Code:
//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());
Re: accessing a specific area in a file...?
Thanks!
I'll try it, and get back to you...