PDA

View Full Version : Moving File/Folder in Qt



arpspatel
15th January 2010, 18:27
Hi,

I am trying to create a program which sorts the files in my download folder automatically as per categories, i want to be able to move files and folders with a progress bar. i am not sure how to approach the moving part of the program. i tried with QFile::copy and them remove recursively, which works but takes too long and gives me transfer error sometimes. is there any other approach, faster and reliable one.

Thanks
Arpit

squidge
15th January 2010, 19:50
I don't know what OS your after, but if it's windows, then you have API function MoveFileWithProgress(), which can use a callback function so you can update a GUI. If it can't actually move the file (eg. it's in use, read only, or whatever) then it'll attempt to copy the file instead.

arpspatel
15th January 2010, 20:25
I don't know what OS your after, but if it's windows, then you have API function MoveFileWithProgress(), which can use a callback function so you can update a GUI. If it can't actually move the file (eg. it's in use, read only, or whatever) then it'll attempt to copy the file instead.

I use windows but i dont see a function called MoveFileWithProgress() in QT. there is one in windows MSDN API in WinBase.h, but i am not sure if i can use with MinGW for compiling.

squidge
15th January 2010, 23:44
Yes, sorry, I meant WinAPI function.

Yes, you can use WinAPI functions such as that with MinGW (Qt, after all, uses WinAPI calls for a lot of it's own work)

arpspatel
17th January 2010, 01:37
Thanks, Tried and worked on first try