| Here's how to delete files using the Windows Recycle Bin from Visual Basic. Code: Option Explicit Private Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAnyOperationsAborted As Boolean hNameMappings As Long lpszProgressTitle As String End Type Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As _ SHFILEOPSTRUCT) As Long Private Const FO_DELETE = &H3 Private Const FOF_ALLOWUNDO = &H40 Private Sub Command1_Click() Dim FileOperation As SHFILEOPSTRUCT Dim lReturn As Long Dim FileName As String 'Delete the test.txt to Recycle Bin FileName = "d:\test.txt" With FileOperation .wFunc = FO_DELETE .pFrom = FileName .fFlags = FOF_ALLOWUNDO End With lReturn = SHFileOperation(FileOperation) End Sub |
Delete files to the Recycle Bin |
Express News India | Freelance ecommerce web development India