i want remove Directory
Solved
General and Desktop
-
Hi.
i want remove folder
QDir dir1;
dir.remove("TEST");Fail.... because
There is a subfolder.
TEST
└A
└B
another wayQProcess pProcess = new QProcess; QString total; total="TEST"; list1<<"-r"+total; pProcess->execute("rm",list1);
This failure
rm: Inappropriate options -- 'L'
-
@ForestPoem
ForQt5
you can tryQDir dir("C:\\Path\\To\\Folder\\Here"); dir.removeRecursively();
-
@Ratzz
thank.
but my QT ver 4.8 -
-
Yes I have tried before.
not remove......cpp
bool ResetSetting::removeDir(const QString & dirName)
{
bool result = true;
QDir dir(dirName);if (dir.exists(dirName)) { Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) { if (info.isDir()) { result = removeDir(info.absoluteFilePath()); } else { result = QFile::remove(info.absoluteFilePath()); } if (!result) { return result; } } result = dir.rmdir(dirName); } return result;
}
////////////////////////////////////////////
.h
static bool removeDir(const QString &dirName);///////////////////////////////////////////
removeDir("TEST");
-
@ForestPoem
I tried the same code you pasted. Works fine even for subfolders with contents.
Where do you pass theQString
dirName?
You should pass the full path name of directoryQString dir="C:/Users/Path_to_test/TEST"; removeDir(dir);