CRLF位于文本文件的最后一行之后

时间:2018-06-18 12:24:20

标签: c# newline

如何避免文本文件中最后一行后面的CRLF字符?

  

头的 LF
      Start_one的 LF
      Start_two的 LF
      Start_three的 CRLF

来源:

 string s = "\nStart_";
 StringBuilder txt = new StringBuilder();
 txt.Append("Header");

 StringBuilder row = new StringBuilder();

 row.Append(s + "one");
 txt.Append(row);
 row.Clear();
 row.Append(s + "two");
 txt.Append(row);
 row.Clear();
 row.Append(s + "three");
 txt.Append(row);
 row.Clear();


 using (StreamWriter sw = File.CreateText(@"C:\Users\***\test.txt"))
 {       
     sw.WriteLine(txt.ToString());
 }

0 个答案:

没有答案