I have a stream reader line by line (sr.ReadLine()
). My code counts the line-end with both line endings \r\n
and/or \n
.
StreamReader sr = new System.IO.StreamReader(sPath, enc);
while (!sr.EndOfStream)
{
// reading 1 line of datafile
string sLine = sr.ReadLine();
...
How to tell to code (instead of universal sr.ReadLine()
) that I want to count new line only a full \r\n
and not the \n
?
It is not possible to do this using StreamReader.ReadLine. As per msdn:
So yoг have to read this stream byte-by-byte and return line only if you've captured \r\n
EDIT
Here is some code sample
You can use it like