Export (0) Print
Expand All

FileSystem.Kill Method

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.


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 SecurityException, and Code 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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

© 2014 Microsoft