Deletes the specified file.
Assembly: mscorlib (in mscorlib.dll)
path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
path is a null reference (Nothing in Visual Basic).
The specified path is invalid (for example, it is on an unmapped drive).
The specified file is in use.
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.
path is in an invalid format.
The 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.
The caller does not have the required permission.
path is a directory.
path specified a read-only file.
Specify a file name with any relative or absolute path information for the path parameter. Wildcard characters cannot be included. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.
If the file to be deleted does not exist, no exception is thrown.
For a list of common I/O tasks, see Common I/O Tasks.
Windows NT 4.0 Platform Note: Delete does not delete a file that is open for normal I/O or a file that is memory mapped.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.