Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Delete file to recycle bin


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 Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40


Public Sub DeleteFileToRecycleBin(Filename As String )
Dim fop As SHFILEOPTSTRUCT
fop.wFunc = FO_DELETE
fop.pFrom = Filename
fop.fFlags = FOF_ALLOWUNDO
SHFileOperation fop
End Sub