Search code examples
javarecycle-bin

Is it possible with Java to delete to the Recycle Bin?


Java is the key here. I need to be able to delete files but users expect to be able to "undelete" from the recycle bin. As far as I can tell this isn't possible. Anyone know otherwise?


Solution

  • For various reasons Windows has no concept of a folder that simply corresponds to the Recycle Bin.

    The correct way is to use JNI to invoke the Windows SHFileOperation API, setting the FO_DELETE flag in the SHFILEOPSTRUCT structure.