hi, how to delete a file in single button?
lets say i want to delete a Myapp.exe using a single button in vb...
and Myapp.exe not showing anymore in recycle bin
thanks..
Printable View
hi, how to delete a file in single button?
lets say i want to delete a Myapp.exe using a single button in vb...
and Myapp.exe not showing anymore in recycle bin
thanks..
the Kill function?
VB Code:
Private sub cmdDeleteFile_Click On error resume next Kill app.path & "\Myapp.exe" On error goto 0 end Sub
The on Error traps are in place for the fact that if MyApp can't be deleted it will raise an error. Resume next will ignore the error, On error goto 0 will allow errors to be raised.
A better way of doing it:
VB Code:
Public Function fDeleteFile(strFilename as string) as Boolean On error goto ErrHandler Kill strFilename fDeletefile = true Exit function ErrHandler: fDeleteFile = false End Function ' You can use this function like: If fDeletefile(app.path & "\MyApp.exe") then Msgbox "File MyApp was deleted.", vbOkOnly + VbInformation, "Deletion" else Msgbox "File MyApp was not deleted due to error: " & err.description, vbOkOnly + VbCritical, "Deletion" end if
Not sending it to the Recycle Bin, or sending it?Quote:
Originally Posted by nokmaster
If not, use Kill like Devion posted.
If yes, use SHFileOperation (I posted an example earlier).
My SHFileOperation example if you're interested.
@Devion
thanks... :)
works perfect
br, :)