I have a need to read - read the first and last lines of a log file in a .NET 4.5 application
, that is.
The log file has timestamps on every line and I want to find the youngest (first line) and oldest (last line) timestamps. This isn't a difficult task but I'm wondering if there's a clever way of doing it.
Currently the implementation looks like this (I actually need the second line of the log file because the first line is blank, hence the Skip()
):
string firstLine = File.ReadLines(logFile).Skip(1);
string lastLine = File.ReadLines(logFile).Last();
Can there be any improvements to this very simple code?