Hi Tarren,
Besides reading all the info like Trond said, if you know that there is nothing after DONE (like line breaks or tabs etc) you could set the StreamReader's position to last position -4
using(FileStream fs = File.OpenRead("c:\\file.dat"))
{
using(StreamReader sr = new StreamReader(fs))
{
sr.BaseStream.Position = fs.Length - 4;
if(sr.ReadToEnd() == "DONE")
// match
}
}
On Mon, 25 Apr 2005 17:00:01 +0200, Tarren <no***********@thanks.com> wrote:
Hi:
I want to check my text file to ensure the last line has only DONE on it,
prior to loading the file.
How can I do this with a StreamReader object to go to the last line so I can
perform the string comparison?
Thanks
--
Happy coding!
Morten Wennevik [C# MVP]