|
|
Title | Move a file into the wastebasket |
Keywords | wastebasket, recycle bin, delete |
Categories | Files and Directories, Utilities |
|
|
Use the SHFileOperation API function. The wFunc parameter tells the function what operation to perform. The FOF_ALLOWUNDO flag moves the file into the wastebasket so you can retrieve it later if you like. The FOF_NOCONFIRMATION flag makes the operation not ask the user for confirmation.
|
|
' Delete the file.
Private Sub CmdDelete_Click()
Dim op As SHFILEOPSTRUCT
With op
.wFunc = FO_DELETE
.pFrom = FilenameText.Text
If chkConfirm.Value = vbChecked Then
' Make the user confirm.
.fFlags = FOF_ALLOWUNDO
Else
' Do not make the user confirm.
.fFlags = FOF_ALLOWUNDO Or FOF_NOCONFIRMATION
End If
End With
SHFileOperation op
MsgBox "Ok"
End Sub
|
|
|
|
|
|