Results 1 to 3 of 3

Thread: Send file / folder to trash

  1. #1
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Send file / folder to trash

    As far as I am aware there's not a procedure to send a file to the trash/ recycle. I tried creating a small module os dependent to attach to each project with small OS invocations such as this.

    First, do you think it's a good idea?, I know this creates dependencies but gives you some flexibility at an apparent simplicity if you know what to call of each OS

    What would be a safe #includestrategy?, in the case of sending objects to the trash in Mac you need to include "Files.h". At the first attempt a row of errors appeared so I thought I'd ask if anyone has the ideas clear and is willing to share some insights.

  2. #2
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Send file / folder to trash

    Hmmm if I were you I'd try move the file directly into the trash using combination QFile::copy() and QFile::remove()-but still system-dependent location of the bin is needed.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Send file / folder to trash

    That will not work for an OS such as Windows, where information about the file (original location, delete date, etc) is stored in a database and the file then renamed to something like Dc3684.jpg when its moved into the trash.

    A better way would to be use SHFileOperation with FO_DELETE and FOF_ALLOWUNDO and let the OS place the files into the recycle bin for you.

  4. The following user says thank you to squidge for this useful post:

    thru (19th May 2011)

Similar Threads

  1. Save File in another Folder
    By GonzoFist in forum General Programming
    Replies: 14
    Last Post: 20th April 2010, 12:59
  2. Moving File/Folder in Qt
    By arpspatel in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2010, 01:37
  3. Release folder - 1 .exe file only
    By Swankee in forum Qt Tools
    Replies: 6
    Last Post: 21st December 2009, 22:43
  4. Can't create folder if file with same name exists
    By Barry79 in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2009, 16:33
  5. Password on local file/folder
    By icebox25 in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2007, 16:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.