Stream Reader getting to the bottom of the file

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I'm using a FileStream, and a StreamReader to read a file. When I open
the file I need to get to the bottom of the file and read some data
about the contents of the file, and then go back to the top and
process through the file (line by line using StreamReader.ReadLine).
Is there any easy way to do this? Can I open the file from the bottom
or anything like that?


jeffpriz
 
Try FileStream.Seek to set the file pointer to the end of the file before
you perform a read. Then call FileStream.Seek again to set the file pointer
to the beginning of the file.

FileStream.Seek(0, SeekOrigin.End)

...read data....


FileStream.Seek(0, SeekOrigin.Begin)
 
Back
Top