c# Programming Glossary: linecount
Determine the number of lines within a text file http://stackoverflow.com/questions/119559/determine-the-number-of-lines-within-a-text-file now you can have both efficiency and conciseness with var lineCount File.ReadLines @ C file.txt .Count Original Answer If you're.. not too bothered about efficiency you can simply write var lineCount File.ReadAllLines @ C file.txt .Length For a more efficient.. .Length For a more efficient method you could do var lineCount 0 using var reader File.OpenText @ C file.txt while reader.ReadLine..
How to read last “n” lines of log file http://stackoverflow.com/questions/4619735/how-to-read-last-n-lines-of-log-file name reader The reader to read from. param param name lineCount The number of lines to return. param returns The last lneCount.. public static string Tail this TextReader reader int lineCount var buffer new List string lineCount string line for int i 0.. TextReader reader int lineCount var buffer new List string lineCount string line for int i 0 i lineCount i line reader.ReadLine if..
|