Creating an empty file in C#

前端 未结 7 508
渐次进展
渐次进展 2020-12-02 07:13

What\'s the simplest/canonical way to create an empty file in C#/.NET?

The simplest way I could find so far is:

System.IO.File.WriteAllLines(filename         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 07:46

    File.WriteAllText("path", String.Empty);
    

    or

    File.CreateText("path").Close();
    

提交回复
热议问题