C# – Clearing content of text file using C#

cfilenettext;

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

Best Answer

File.WriteAllText(path, String.Empty);

Alternatively,

File.Create(path).Close();