FileSystem.Kill Method (String)

 

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
)

Parameters

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
IOException

Target file(s) open.

FileNotFoundException

Target file(s) not found.

SecurityException

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.
Kill("*.TXT")

.NET Framework
Available since 1.1
Return to top
Show: