C# - Appending text files

前端 未结 4 2099
遇见更好的自我
遇见更好的自我 2020-12-31 13:24

I have code that reads a file and then converts it to a string, the string is then written to a new file, although could someone demonstrate how to append this string to the

4条回答
  •  一个人的身影
    2020-12-31 13:48

    Use File.AppendAllText

    File.AppendAllText("c:\\test2.txt", myString)
    

    Also to read it, you can use File.ReadAllText to read it. Otherwise use a using statement to Dispose of the stream once you're done with the file.

提交回复
热议问题