Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Restore File From Recycle Bin

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Resolved [RESOLVED] [2005] Restore File From Recycle Bin

    Hello again!
    In my program I need to be able to send them files to the recycle bin; then, there is also a need to be able to restore files from the recycle bin.

    Sending to the recycle bin is covered with :
    Code:
            My.Computer.FileSystem.DeleteFile(SelFileName, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.DoNothing)
    How can I restore a deleted file from the recycle bin, if someone sent the wrong file to it?

  2. #2
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: [2005] Restore File From Recycle Bin

    I'm not sure that the restore option is available, but here is an alternative,
    opent the recycle bin folder, cut and paste file back to it's original location.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Restore File From Recycle Bin

    Hi, thanx for the advice, but I need to be able to do this from my program

  4. #4
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: [2005] Restore File From Recycle Bin

    within your program, when the restore button is click, u then navigate to the recycle bin and restore the selected file.
    I don't vb right now so can't give you an example.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Restore File From Recycle Bin

    OK, I just shelled the Recycle Bin, meaning I opened it up from my program. Customers are happy with that

    This is how you sheel the RecycleBin from your application ( in case someone is interested) :
    Code:
        <DllImport("shell32.dll", EntryPoint:="ShellExecute", SetLastError:=True, CharSet:=CharSet.Auto)> _
            Private Shared Function ShellExecute(ByVal hwnd As Int32, ByVal lpOperation As String, _
            ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
            ByVal nShowCmd As Int32) As Int32
        End Function
    
        <DllImport("shell32.dll", EntryPoint:="GetDesktopWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
            Private Shared Function GetDesktopWindow() As Int32
        End Function
    
        Private Const SW_SHOWMAXIMIZED As Long = 3
        Private Const SW_SHOWDEFAULT As Long = 10
    
        Private Sub RunShellExecute(ByVal sTopic As String, _
        ByVal sFile As Object, _
        ByVal sParams As Object, _
        ByVal sDirectory As Object, _
        ByVal nShowCmd As Long)
    
            Dim hWndDesk As Long
            Dim success As Long
    
            'the desktop will be the
            'default for error messages
            hWndDesk = GetDesktopWindow()
    
            'execute the passed operation
            success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory, nShowCmd)
    
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim sTopic As String
            Dim sFile As String
            Dim sParams As String
            Dim sDirectory As String
            'set default setting to be used
            'if not specifically required
            sTopic = "Open"
            sDirectory = vbNullString
            sFile = "explorer.exe"
            'hkeylocalmachine\software\microsoft\windowsnt\currentversion\winlogon\shell
            sParams = "/n,::{645FF040-5081-101B-9F08-00AA002F954E}"
    
            RunShellExecute(sTopic, sFile, sParams, sDirectory, SW_SHOWDEFAULT)
    
        End Sub

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