 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Delete a file in C#
Use File.Delete method to delete a file.
Firstly, set the path of the file you want to delete.
String myPath = @"C:\New\amit.txt";
Now, use the File.Delete method to delete the file.
File.Delete(myPath);
The following is the complete code −
Example
using System; using System.IO; public class Program {    public static void Main() {       String myPath = @"C:\New\amit.txt";       Console.WriteLine("Deleting File");       File.Delete(myPath);    } }  Output
Deleting File
Advertisements
 