DeleteFile Function

Declare Function DeleteFile Lib "kernel32.dll" Alias "DeleteFileA" (ByVal lpFileName As String) As Long

Platforms: Win 32s, Win 95/98, Win NT

DeleteFile deletes a file completely -- it does not send it to the Recycle Bin. It also doesn't prompt to confirm the deletion, so use it carefully. The function returns 1 if successful, or 0 if an error occured (most likely the file doesn't exist).

lpFileName
The name of the file to delete.

Example:

' Delete the file C:\Dummy\thefile.txt
Dim retval As Long  ' return value

retval = DeleteFile("C:\Dummy\thefile.txt")
If retval = 1 Then Debug.Print "File deleted successfully."
Category: Files
Back to the index.

Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/d/deletefile.html