Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMove a file into the wastebasket
Keywordswastebasket, recycle bin, delete
CategoriesFiles and Directories, Utilities
 
Use the SHFileOperation API function. The wFunc parameter tells the function what operation to perform. The FOF_ALLOWUNDO flag moves the file into the wastebasket so you can retrieve it later if you like. The FOF_NOCONFIRMATION flag makes the operation not ask the user for confirmation.
 
' Delete the file.
Private Sub CmdDelete_Click()
Dim op As SHFILEOPSTRUCT

    With op
        .wFunc = FO_DELETE
        .pFrom = FilenameText.Text
        If chkConfirm.Value = vbChecked Then
            ' Make the user confirm.
            .fFlags = FOF_ALLOWUNDO
        Else
            ' Do not make the user confirm.
            .fFlags = FOF_ALLOWUNDO Or FOF_NOCONFIRMATION
        End If
    End With
    SHFileOperation op

    MsgBox "Ok"
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated