View Full Version : Deleting a file

12th August 2010, 13:55
Hi Everyone,
Can anyone tell me how to delete a file in Qt. I have tried QFile::remove and QDir::remove. But none of them are working as my expectation. Any help will be appreciated.

12th August 2010, 14:09
For me they work perfect. What do you expect and are you sure you set the right file, which you want delete?

12th August 2010, 14:14
I have created one database and place it into c:\oxscan\dbFile.db. Now I want to either delete it or clear the contents of it. So I have used the following code;

QFile File("C:\\Oxscan\\dbFile.DB");
bool bRemoved = File.remove();

12th August 2010, 14:16
... and the after that bRemoved is true or false?

If false, the file is probably in use, so windows does not permit to delete it.

12th August 2010, 14:19
bRemoved is false. So if I call File.close(), will it work.

12th August 2010, 14:30
Thanks for your help. Now it is not required to delete the file. I have just deleted the contents and working as my expectation.