1

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?

Alexander V
  • 8,351
  • 4
  • 38
  • 47
OMG_Soruce
  • 96
  • 1
  • 2
  • 9

1 Answers1

3
bool removeDirRecursively(const QString& dirPath)
{
    QDir dir(dirPath);
    bool r = dir.removeRecursively();
    qDebug() << "The directory remove operation " <<
         (r ? "finished successfully" : "failed");
}
Alexander V
  • 8,351
  • 4
  • 38
  • 47