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

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/d/deletefile.html