Wait a minute, I've come up with another iteration of this and this time it will not remove your empty lines. Dunno why I didn't think of it earlier:
string CRLF = "\r\n";
string CR = "\r";
string LF = "\n";
string TestString = string.Format("Test this string. {0}It contains {1}{2}a blank line.", CRLF, CRLF, CRLF);
TestString = TestString.Replace(LF, "");
string[] lines = TestString.Split(CR.ToCharArray());
for (int i = 0; i < lines.Length; i++)
{
Debug.WriteLine(lines[i]);
}
The only thing I haven't tested is performance, but since you have the large strings, I'll leave that up to you.
~~Bonnie
>>Well, that is weird behavior (the thing with the LF). If your empty lines contain more than just a CRLF (like, say they contain a space or a tab), then my example will retain that "empty" line. But, anyway, it doesn't matter ... it sounds like you found a workable solution.
>
>Yes, it is just that I have to scan all the lines, after I have populated the string builder, to remove the LF character. Like I said, this does not happen on the first line but only on all upcoming ones.