Delete File using DeleteFile API:   Return to List

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

Private Sub Form_Load()
    Dim intResult As Long ' return value
    intResult = DeleteFile("C:\Temp.txt")' Doesn't go to Recycle Bin!
    If intResult = 1 Then
        MsgBox "File deleted."
    Else
        MsgBox "Encountered Error. Couldn't Delete!"
    End If
    End
End Sub



Note to Webmaster