StreamWriter add an extra \r in the end of the line

前端 未结 4 1916
我在风中等你
我在风中等你 2021-01-18 08:32

I created a class with the responsibility to generate a text file where each line represents the information of an object of \'MyDataClass\' class. Below is a simplification

4条回答
  •  无人及你
    2021-01-18 09:18

    I had a similar issue. Environment.NewLine and WriteLine gave me extra \r character. But this below worked for me:

    StringBuilder sbFileContent = new StringBuilder();
    sbFileContent.Append(line);
    sbFileContent.Append("\n");
    streamWriter.Write(sbFileContent.ToString());
    

提交回复
热议问题