Click or drag to resize
FileDelete Method
Deletes the specified file.

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static void Delete(
	string path
)

Parameters

path
Type: SystemString
The name of the file to be deleted. Wildcard characters are not supported.
Exceptions
ExceptionCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
ArgumentNullExceptionpath is null.
DirectoryNotFoundExceptionThe specified path is invalid (for example, it is on an unmapped drive).
IOExceptionThe specified file is in use. -or-There is an open handle on the file, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
NotSupportedExceptionpath is in an invalid format.
PathTooLongExceptionThe specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
UnauthorizedAccessExceptionThe caller does not have the required permission.-or- path is a directory.-or- path specified a read-only file.
See Also