FileSystem.Kill Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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 .

Namespace:   Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static void Kill(
	string PathName


Type: System.String

Required. String expression that specifies one or more file names to be deleted. PathName can include the directory or folder, and the drive.

Exception Condition

Target file(s) open.


Target file(s) not found.


Permission denied.

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

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.

.NET Framework
Available since 1.1
Return to top