Cancella Files dalla cartella recycle




Option Explicit
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type

Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Public Function ShellDelete(ParamArray vntFileName() As Variant) As Long

Dim I As Integer
Dim sFileNames As String
Dim SHFileOp As SHFILEOPSTRUCT

For I = LBound(vntFileName) To UBound(vntFileName)
sFileNames = sFileNames & vntFileName(I) & vbNullChar
Next
sFileNames = sFileNames & vbNullChar

With SHFileOp
.wFunc = FO_DELETE
.pFrom = sFileNames
.fFlags = FOF_ALLOWUNDO
End With

ShellDelete = SHFileOperation(SHFileOp)

End Function

'The function's ParamArray argument allows you to pass it any number of

'file names:

'Delete a single file


lResult = ShellDelete("DELETE.ME")

' Delete several files

lResult = ShellDelete("DELETE.ME", "LOVE_LTR.DOC", "COVERUP.TXT")











( cancellafilesdallacartellarecycle.html )- by Paolo Puglisi - Modifica del 17/12/2023