Hello all,
I'm trying to send the deleted files to recycle bin folder, I found the following code:
++++++module code +++++++
Public Type SHFILEOPSTRUCT
wFunc As Long
hwnd As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTilte As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_DELETE = &H3
Public Const FOF_ALLOWUNDO = &H40
Public Const FOF_CREATEPROGRESSDLG As Long = &H0
++++++++++++ form code +++++
Public Function DelToRecyBin(filename As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim IReturn As Long
On Error GoTo DeltoRecycBin_Err
With FileOperation
.wFunc = FO_DELETE
.pFrom = filename
.fFlags = FOF_ALLOWUNDO ' + FOF_CREATEPROGRESSDLG
End With
IReturn = SHFileOperation(FileOperation)
SHFileOperation FileOperation
Exit Function
DeltoRecycBin_Err:
MsgBox Err.Description
End Function
+++++ calling t he function +++++
DelToRecyBin ("path\filename.ext")
the thing is that it doesn't send the files to the recycle bin, yit will read the code and NO error message will appear but
it does not send the files.
Am I missing something???? do you have another code sugestion???
THank you
EP
I'm trying to send the deleted files to recycle bin folder, I found the following code:
++++++module code +++++++
Public Type SHFILEOPSTRUCT
wFunc As Long
hwnd As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTilte As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_DELETE = &H3
Public Const FOF_ALLOWUNDO = &H40
Public Const FOF_CREATEPROGRESSDLG As Long = &H0
++++++++++++ form code +++++
Public Function DelToRecyBin(filename As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim IReturn As Long
On Error GoTo DeltoRecycBin_Err
With FileOperation
.wFunc = FO_DELETE
.pFrom = filename
.fFlags = FOF_ALLOWUNDO ' + FOF_CREATEPROGRESSDLG
End With
IReturn = SHFileOperation(FileOperation)
SHFileOperation FileOperation
Exit Function
DeltoRecycBin_Err:
MsgBox Err.Description
End Function
+++++ calling t he function +++++
DelToRecyBin ("path\filename.ext")
the thing is that it doesn't send the files to the recycle bin, yit will read the code and NO error message will appear but
it does not send the files.
Am I missing something???? do you have another code sugestion???
THank you
EP