Results 1 to 6 of 6

Thread: How can I delete to Recycle Bin with VB6

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    PORTUGAL
    Posts
    18

    Question

    How can I send a file or files to Recycle Bin with VB6. I want to delete some in a routine of mine but I don't want a permanently delete. I want the user catch it if he wants.

    My best regards

    José Nogueira
    Eng. José Nogueira
    Mail: [email protected]
    Web: planeta.clix.pt/janogueira
    Entroncamento-Santarém-PORTUGAL

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try here http://msdn.microsoft.com/vbasic/tec...ps.asp#8-14-00

    There is actually lots of cool stuff on this site.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    PORTUGAL
    Posts
    18

    It doesn't work properly...

    I tried Edneeis suggestion but it didn't work as I expected.
    First, it doesn't send the file to the Recycle Bin but perform a delete. Second, it makes the confirmation question and I'd rather prefer no questions.

    Who can help me?

    My best regards

    José Nogueira
    Eng. José Nogueira
    Mail: [email protected]
    Web: planeta.clix.pt/janogueira
    Entroncamento-Santarém-PORTUGAL

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    try the fofSilent flag

    in the example provided
    use that with the allowundo

  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Under the Windows API link on the VB-World home page, there is a link to a web page with info on this subject: http://visualbasic.about.com/compute...y/aa072999.htm


  6. #6
    Guest
    Don't forget to recycle .

    Code:
    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 Const FOF_CREATEPROGRESSDLG As Long = &H0
    Public Enum RemoveAction
        rfRecycle = 1
        rfDelete = 2
    End Enum
    
    
    Function Recycle(filename As String, action As RemoveAction) As Boolean
        Dim FileOperation As SHFILEOPSTRUCT
        Dim lReturn As Long
        On Error GoTo RemoveFile_Err
        With FileOperation
            .wFunc = FO_DELETE
            .pFrom = filename
            If action = rfRecycle Then
                .fFlags = FOF_ALLOWUNDO + FOF_CREATEPROGRESSDLG
            Else
                .fFlags = FO_DELETE + FOF_CREATEPROGRESSDLG
            End If
        End With
        lReturn = SHFileOperation(FileOperation)
        If lReturn <> 0 Then
            RemoveFile = False
        Else
            RemoveFile = True
        End If
        Exit Function
    RemoveFile_Err:
        RemoveFile = False
    End Function
    If you are using VB4:

    Code:
    Public Type SHFILEOPSTRUCT
        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
    
    Public Declare Function SHFileOperation Lib _
    "shell32.dll" Alias "SHFileOperationA" (lpFileOp _
    As SHFILEOPSTRUCT) As Long
    
    Public Const FO_DELETE = &H3
    Public Const FOF_ALLOWUNDO = &H40      
    Code
    Dim SHop As SHFILEOPSTRUCT
    Dim strFile as string
    
    With SHop
        .wFunc = FO_DELETE
        .pFrom = strFile '<-file to recycle
        .fFlags = FOF_ALLOWUNDO
    End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width