Zählt die Zeilen einer Datei.
benötigte Namespaces:
System.IO
/// <summary>
/// Counts the lines of a File.
/// </summary>
/// <param name="fileToCount">The file to count.</param>
/// <returns>lines of a File</returns>
private static int CountLines(string fileToCount)
{
int counter = 0;
using (StreamReader countReader = new StreamReader(fileToCount))
{
while (countReader.ReadLine() != null)
counter++;
}
return counter;
}
1 Kommentare zum Snippet