Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Deletes files from a disk. The My
feature gives you better productivity and performance in file I/O operations than Kill
. For more information, see FileSystem .
public:
static void Kill(System::String ^ PathName);
public static void Kill(string PathName);
static member Kill : string -> unit
Public Sub Kill (PathName As String)
Required. A string expression that specifies one or more file names to be deleted. PathName
can include the directory or folder, and the drive.
Target file(s) open.
Target file(s) not found.
Permission denied.
This example uses the Kill
function to delete a file from a disk.
' Assume TESTFILE is a file containing some data.
Kill("TestFile") ' Delete file.
' Delete all *.TXT files in current directory.
Kill("*.TXT")
Kill
supports the use of multiple-character (*
) and single-character (?
) wildcards to specify multiple files.
Security Note In order to execute, the Kill
function requires Read
and PathDiscovery
flags of FileIOPermission to be granted to the executing code. For more information, see SecurityExceptionCode Access Permissions
Product | Versions |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in