Write string to text file and ensure it always overwrites the existing content.

前端 未结 4 715
离开以前
离开以前 2020-12-04 08:35

I have a string with a C# program that I want to write to a file and always overwrite the existing content. If the file isn\'t there, the program should create a new file i

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 09:13

    Use the File.WriteAllText method. It creates the file if it doesn't exist and overwrites it if it exists.

提交回复
热议问题