Re: Downloading unix \n text files, convert to \r\n non-unix?



Arne Vajhøj wrote:
Zytan wrote:
Should I do a String.Replace(), or is there a better solution?

String.Replace("\n", "\r\n") doesn't work. It doesn't change
anything.

It should.

string s = "A\nBB\nCCC";
Console.WriteLine(s.Length);
s = s.Replace("\n", "\r\n");
Console.WriteLine(s.Length);

prints 8 and 10 for me !

But I think:

string s = "A\nBB\nCCC";
Console.WriteLine(s.Length);
s = Regex.Replace(s, "(?<!\r)\n", Environment.NewLine);
Console.WriteLine(s.Length);

is better code !

Arne
.