Count file lines in C# -
i want know how many lines have in file. how can in simple way (i mean, not go through on over file , count each line)? there command that?
well:
int lines = file.readalllines(path).length;
is simple, not efficient huge text files. i'd use textreader
in cases, avoid excessive buffering:
int lines = 0; using (textreader reader = file.opentext(path)) { while (reader.readline() != null) { lines++; } }
Comments
Post a Comment