coba coding berikut ini :
Private Type SHFILEOPTSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias
"SHFileOperationA" (lpFileOp As SHFILEOPTSTRUCT) As Long
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias
"SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As
String, ByVal dwFlags As Long) As Long
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Public Sub DeleteFileToRecycleBin(Filename As String)
Dim fop As SHFILEOPTSTRUCT
With fop
.wFunc = FO_DELETE
.pFrom = Filename
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation fop
End Sub
Private Sub Command1_Click()
DeleteFileToRecycleBin Text1.Text
End Sub
Private Sub Command2_Click()
CommonDialog1.DialogTitle = "Open File"
CommonDialog1.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.Filename
End Sub
Private Sub Command3_Click()
SHEmptyRecycleBin Me.hwnd, "", SHERB_NOSOUND
' SHERB_NOCONFIRMATION
' No dialog box confirming the deletion of the objects will be
displayed.
' SHERB_NOPROGRESSUI
' No dialog box indicating the progress will be displayed.
' SHERB_NOSOUND
End Sub
semoga membantu