Home > Language Reference > File Functions > Kill

Kill

The Kill function deletes one or several files.

Usage

Do not kill files using Del key in Explorer: the selection of the file to kill is not reliable as the way to display files in Explorer depends on Windows settings for each user. Use instead Kill function. Wildcards (* or ? characters) are allowed in the file names. As Kill returns an error if you try to delete a file which does not exist, you can first check that the file exists using Exist function.
When you download a file from Internet, if the file already exists on your PC, you get a message asking if you want to replace it. To avoid this possible message, use Exist function to test if the file already exists, and if yes, use Kill function to delete it.

Syntax

ret=Kill(<filename>)

Parameters

<filename>, string, name of the file to delete. Wildcards (* or ? characters) are allowed in <filename>.

Return value

ret,  optional numeric return value. If the function has successfully deleted the file, the return value is 0. If the function fails, the return value is a nonzero value (see File Functions Error Codes). 

See also

Exist

Examples

Kill("c:\wttest\*.txt")

Result = Kill(file$)
msgbox(result)