I have several web site files that I have to edit systematically. Therefore, I have written a small program that changes certain lines. I read the content with
List<string> list = new List<string>(
File.ReadAllLines(fileName,
Encoding.GetEncoding(1252))
);
make the changes, and save the content with
System.IO.StreamWriter file = new System.IO.StreamWriter(fileName, false, Encoding.GetEncoding(1252));
file.WriteLine(content);
Sadly, this saves the content in one single line without line breaks. Could you please tell me which other function I have to use or how I have to adjust the code so the original line breaks don’t get lost in the process of writing the file?
Try to use File.WriteAllLines method instead:
As per MSDN:
Code: