I want to read a text file from last line because it could be big size and just want to check today's log content.
I'm using File.ReadLines() and success to read last line.
How can I read the previous line?
Or is there any way to get the current line number so that I can subtract the number?
foreach (string f in Directory.GetFiles(sDir, "*.log", SearchOption.AllDirectories))
{
string last = File.ReadLines(f, Encoding.Default).Last(); //read Last Line here
if (last.IndexOf("error", StringComparison.OrdinalIgnoreCase) > 0)
{
WriteError(last);
}
}