Deletes the specified file.
Namespace: System.IOAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static void Delete(
string path
)
Parameters
- path
- Type: SystemString
The name of the file to be deleted. Wildcard characters are not supported.
Exceptions Exception | Condition |
---|
ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars. |
ArgumentNullException | path is null. |
DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
IOException | The 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. |
NotSupportedException | path is in an invalid format. |
PathTooLongException | 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. |
UnauthorizedAccessException | The caller does not have the required permission.-or- path is a directory.-or- path specified a read-only file. |
See Also