Search code examples
c#.nettextfile

Clearing content of text file using C#


How can I clear the content of a text file using C# ?


Solution

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

    Alternatively,

    File.Create(path).Close();