StreamWriter: How to add a new line?

前端 未结 2 801
醉酒成梦
醉酒成梦 2021-01-23 23:33

I want to write a string into a file. My problem is that I cannot add new lines into the file.

using (System.IO.StreamWriter writer = new System.IO.StreamWriter(         


        
相关标签:
2条回答
  • 2021-01-24 00:13

    Maybe platform issues? Look at Difference between "\n" and Environment.NewLine Try Environment.NewLine

    writer.Write(String.Format("{0}{2}{2}{1}", this.currentRealWorldObj.Title, this.currentRealWorldObj.Description,Environment.NewLine));
    
    0 讨论(0)
  • 2021-01-24 00:13

    There is a specific WriteLine function for this.

    For example:

    writer.WriteLine(this.currentRealWorldObj.Title);
    writer.WriteLine();
    writer.WriteLine();
    writer.WriteLine(this.currentRealWorldObj.Description);
    
    0 讨论(0)
提交回复
热议问题