Stream Reader getting to the bottom of the file

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
 
C

Christine Nguyen

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top