Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,420 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The following code reads in the file OK. It splits the text into several lines without end-of-line terminators OK. But even though the Split has the TrimEntries option, it still returns several lines of zero length. Why? How to remove zero-length entries with Split? Is this another MS bug?
char[] charSeparators = new char[] { '\x0A', '\x0C', '\x0D' };
using (StreamReader sr = new StreamReader(fileNm))
{
content = sr.ReadToEnd();
linesIn = content.Split(charSeparators,
StringSplitOptions.RemoveEmptyEntries
& StringSplitOptions.TrimEntries);
sr.Close();
}
Just a guess but did you mean to bitwise OR these instead of AND?
StringSplitOptions.RemoveEmptyEntries & StringSplitOptions.TrimEntries