Read last line of text file
There are two ways: simple and inefficient, or horrendously complicated but efficient. The complicated version assumes a sane encoding. Unless your file is so big that you really can’t afford to read it all, I’d just use: var lastLine = File.ReadLines(“file.txt”).Last(); Note that this uses File.ReadLines, not File.ReadAllLines. If you’re using .NET 3.5 or earlier … Read more