Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using recycle bin to send deleted files

Status
Not open for further replies.

nkyeshi01

Programmer
Nov 4, 2004
29
US
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 don't think you need the line : SHFileOperation FileOperation. Does the function call from within your form? What is the line you are using to call the function?

BB
 
I'n using the line
DelToRecyBin ("path\filename.ext") to call the function, I call it from another sub that I have.

Thanks for responding

Ep
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top