How to add new line into txt file

后端 未结 4 2018
执笔经年
执笔经年 2020-11-28 23:47

I\'d like to add new line with text to my date.txt file, but instead of adding it into existing date.txt, app is creating new date.txt file..

TextWriter tw =         


        
4条回答
  •  抹茶落季
    2020-11-29 00:31

    Why not do it with one method call:

    File.AppendAllLines("file.txt", new[] { DateTime.Now.ToString() });
    

    which will do the newline for you, and allow you to insert multiple lines at once if you want.

提交回复
热议问题