Results 1 to 9 of 9

Thread: [2005] How to move file to Recycle Bin

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Location
    C:\Downloads at 87.105.109.239
    Posts
    39

    [2005] How to move file to Recycle Bin

    What code do I use to move file to recycle bin?
    Let's say that I have a file C:\sample.txt and I want to place it in the bin.

  2. #2
    "The" RedHeadedLefty
    Join Date
    Aug 2005
    Location
    College Station, TX Preferred Nickname: Gig Current Mood: Just Peachy Turnons: String Manipulation
    Posts
    4,495

    Re: [2005] How to move file to Recycle Bin

    I was thinking maybe moving it to that folder, but the folder path could be different on any one machine, and the Environment.SpecialFolder enumeration doesnt contain an entry for the current user's recycle bin folder (or any recycle bin folder, for that matter). I checked around and it looks like you can do it using the SHFileOperation API, and you can find an example of it here:

    http://www.developerfusion.co.uk/show/120/

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2005
    Location
    C:\Downloads at 87.105.109.239
    Posts
    39

    Resolved Re: [2005] How to move file to Recycle Bin

    OK, I think I've got it; quite easy, just use one of the My.Computer.FileSystem.DeleteFile() overloads. You needn't any special APIs, and you have also a dialog box

  4. #4
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: [2005] How to move file to Recycle Bin

    This does not seem to work on network shares.
    VB Code:
    1. My.Computer.FileSystem.DeleteFile(FInfo.FullFileName, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
    In life you can be sure of only two things... death and taxes. I'll take death.

  5. #5
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: [2005] How to move file to Recycle Bin

    i would recommend selecting the file by clicking it with the left mouse button. after that i would recommend also (if possible) presseing the small keyboard button located in the left bottom with a del. key written on it.

    you will have a confirmation message box, i would finally recommend clicking yes (but i am not sure)

    loooooooooooooooooool, sorry just kidding you, i think the bottom line is to move the file to the recycler folder on the drive instead of directly deleting it.

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2005
    Location
    C:\Downloads at 87.105.109.239
    Posts
    39

    Re: [2005] How to move file to Recycle Bin

    I don't think that it is possible to move file from network share to the recycle bin, even in Windows, but I'm not sure as I don't work in a network very often.

  7. #7
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: [2005] How to move file to Recycle Bin

    Problem is, it is a linux file server.
    In life you can be sure of only two things... death and taxes. I'll take death.

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] How to move file to Recycle Bin

    Doesn't matter, when you access data on a server, if you attempt to delete the file your only option is for an immediate delete. You can't move items from the network into your recycle bin.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  9. #9
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: [2005] How to move file to Recycle Bin

    Lame. That would be a nice feature. I guess you could always move them to a temp folder instead of deleting them.
    In life you can be sure of only two things... death and taxes. I'll take death.

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