C# File Delete

Description

File Delete Deletes the specified file.

Syntax

File.Delete has the following syntax.


public static void Delete(
  string path
)

Parameters

File.Delete has the following parameters.

  • path - The name of the file to be deleted. Wildcard characters are not supported.

Returns

File.Delete method returns

Example

File.Delete


//  w w  w.  j  ava 2s .  co m
using System;
using System.IO;
public class MainClass
{
    public static void Main(String[] argv)
    {
        File.Delete("yourPathName");
        System.Console.WriteLine("delete a file");
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter