KILL statement

Purpose

Delete a disk file.

Syntax

KILL filespec

Remarks

filespec is a string expression specifying the file or files to be deleted, and can include a path name and/or "wildcard" characters.  filespec may be either a Short File Name (SFN) or a Long File Name (LFN).  For example:

KILL "TEST.DOC"

KILL "C:\MY APPLICATION DATA\INCOME.?87"

MyFile$ = "*.BAS"

KILL MyFile$     ' Potentially dangerous!

If filespec does not exist, Error 53 ("File not found") is generated. If filespec is read only, Error 70 ("Permission denied") occurs.  You should not attempt to KILL an open file.

Files with the HIDDEN or SYSTEM attribute can not be deleted with KILL.  An attempt to do so is ignored, with no error generated.

KILL is analogous to the DOS "DEL" and "ERASE" commands.  KILL cannot delete a directory - use RMDIR instead, after first deleting all the files in the directory.

See also

FILEATTR, FILECOPY, FILENAME$, GETATTR, NAME, RMDIR, SETATTR, SETEOF