No announcement yet.

moving things to the recycle bin

  • Filter
  • Time
  • Show
Clear All
new posts

  • moving things to the recycle bin

    For my epub reader, I was going to remove all the files in the directory I extracted the files into when someone chooses an epub file for reading.
    The problem though, is that if something goes wrong for whatever reason, I could wind up removing files in wrong directories, and I don't want to be responsible for removing system critical files. (or even just user files that they wanted to keep).
    So, it occurred to me, that this is exactly what the recycle bin is for.
    After someone is finished with the epub file, and clicks the fiished button on the last chapter of the file, It already removes the bookmark file I use to pick up where they left off, but I'd also like to remove the epub directory I created when they selected the file (epub files are just zip files that need uncompressed to get at their content). If I could simply move this directory to the recycle bin, it would save me potential issues (not that I expect any you understand, I'm simply being cautious here), and it would allow users to retrieve any accidentally finished books assuming users will at times press the finished button when they aren't actually finished with it.
    Of course, they could easily just open it again, but in doing so, they'd loose the bookmark file and any future enhancements such as notes or links saved in the book, so does anyone know what the api call is for windows (and how to use it) to move something to the recycle bin?
    This way, when they click finished, I can simply move the whole epub book into the recycle bin and be done with it.
    (I don't recall seeing a recycle bin path in the get special folders call).
    is ther one?]

    for hosting/internet


  • #2
    I suspect you will need the iFileOperation interface if on Win 8 or later

    or ShFileOperation if using an earlier version

    (IFIleOperation was introduced with Vista, but only got FOFX_RECYCLEONDELETE in Win 8


    • #3
      Sample code from Gary here for ShFileOperation. Still seems to work fine on Windows 7 and 10.
      Rgds, Dave


      • #4
        You may also have a look at RecycleBin