How can I clear the content of a file?

后端 未结 6 1757
慢半拍i
慢半拍i 2020-12-02 21:48

I need to clear the contents of a particular file every time the applications starts. How do I do it?

6条回答
  •  Happy的楠姐
    2020-12-02 22:31

    You can use the File.WriteAllText method.

    System.IO.File.WriteAllText(@"Path/foo.bar",string.Empty);
    

提交回复
热议问题