Pages

Friday, May 22, 2009

Reading last line in text file

StreamReader streamReader = new StreamReader("HereWillBeYourTextFilePath");
ArrayList lines = new ArrayList();

string line;

while ((line = streamReader.ReadLine()) != null)
{
lines.Add(line);
}
streamReader.Close();

if (lines.Count > 0)
{
Response.Write(lines[lines.Count - 1].ToString());
}

No comments:

Shared Button