Visual Basic Language Reference  

Kill Function

Deletes files from a disk.

Public Sub Kill(ByVal PathName As String)

Parameter

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

Exceptions/Errors

Exception type Error number Condition
IOException 55 Target file(s) open.
FileNotFoundException 53 Target file(s) not found.

Remarks

Kill supports the use of multiple-character (*) and single-character (?) wildcards to specify multiple files.

Example

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")   

See Also

RmDir Function | IOException | FileNotFoundException