Languages
[Edit]
EN

C# / .NET - delete file

9 points
Created by:
Root-ssh
175460

In this article, we would like to show how to delete file using C# / .NET.

Quick solution:

// using System.IO;

File.Delete(@"C:\path\to\file.txt");

 

Practical example

using System.IO;

public static class Program
{
	public static void Main(string[] args)
	{
		string path = @"C:\path\to\file.txt";

		File.Delete(path);
	}
}

Example result:

  1. File.Delete() Method - Microsoft Docs
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# / .NET - file API

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join