File::Delete Method (String^)
Deletes the specified file.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- path
-
Type:
System::String^
The name of the file to be deleted. Wildcard characters are not supported.
| 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- The file is an executable file that is in use. -or- path is a directory. -or- 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.
Delete does not delete a file that is open for normal I/O or a file that is memory mapped.
for deleting the specified file. Associated enumeration: FileIOPermissionAccess::Write
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0