PDA

View Full Version : File exists even if it should have deleted



davidlamhauge
26th January 2014, 15:49
Hi
I'm working on a storyboard program, and something puzzles me.
I'm saving the storyboard pads as PNG-files. If I want to erase a pad, I want to erase the file as well.
Here is the code. ('ret' is the return value from a QMessageBox)


qDebug() << projFilePath + sceneDir + "/" + padInfo[fileName];
QFile fPad;
fPad.setFileName(projFilePath + sceneDir + "/" + padInfo[fileName]);
switch (ret) {
case QMessageBox::Ok:
qDebug() << "OK pressed";
if (!fPad.remove())
qDebug() << "delete file failure";

There are three qDebug-messages:
The first writes the correct path. It is checked and doublechecked.
The second is written and proves that I indeed pressed 'OK'.
The third is not written, meaning that the file was removed.

When I run the code in debug mode, the file 'fPad' goes from 'exists = true' to 'exists = false'.

But - the file is not deleted... Please help with any suggestions to solve this.

davidlamhauge
27th January 2014, 02:28
Solved! - and I don't know how...

Frustrations made me to put it aside for most of the day, and now it works.
It is the code above that does the trick. Curious...:confused: