Reputation: 106
I want to remove folder:
QDir dir1;
dir.remove("TEST");
Failed, because there is a subfolder:
TEST
└A
└B
Also tried another way:
QProcess pProcess = new QProcess;
QString total;
total="TEST";
list1<<"-r"+total;
pProcess->execute("rm",list1);
This time it fails with:
rm: Inappropriate options -- 'L'
How can I delete the directory with sub-directories?
Upvotes: 1
Views: 1845
Reputation: 8698
bool removeDirRecursively(const QString& dirPath)
{
QDir dir(dirPath);
bool r = dir.removeRecursively();
qDebug() << "The directory remove operation " <<
(r ? "finished successfully" : "failed");
}
Upvotes: 3