Search This Blog

Thursday, December 10, 2015

Clear contents of a file c#

C# > Clear contents of a file

WriteAllText creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten.

Example

 System.IO.File.WriteAllText(filename, string.Empty);