PDA

View Full Version : Send file / folder to trash



thru
15th May 2011, 10:53
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.

MasterBLB
15th May 2011, 14:10
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.

squidge
15th May 2011, 15:42
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.