Ignora collegamentiHome / Blog

Blog


How to delete a file in C#

Deleting a file with C # is simple!
You can use the Delete method of the File class

using System.IO;

class DeleteFileTest
{
	public static void Main()
	{
	// Path of the file to be deleted.
	string pathOfFile = "C:\\MyDirectory\\FileName.txt";

	// Delete the file
	File.Delete(pathOfFile);
	}
}


Category: C#