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

前端 未结 4 1917
我在风中等你
我在风中等你 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:23

    According to MSDN, WriteLine

    Writes data followed by a line terminator to the text string or stream.

    your last line should be

     _streamWriter.Write(line);
    

    Put it outside of your loop and change your loop so it doesn't manage the last line.

提交回复
热议问题