hi ,
I want to delete a directory empty or not empty in a easier way.
I dont want to use loop to iterate through the files and delete one by one.
Printable View
hi ,
I want to delete a directory empty or not empty in a easier way.
I dont want to use loop to iterate through the files and delete one by one.
...
Ok sorry, you wanted empty or not...
So, rmdir won't work in this case.Quote:
I want to delete a directory empty or not empty in a easier way.
See QDir::entryList() for a list of files and dirs. You need a recursive function to traverse the directory hierarchy and delete the files one by one.
There is no other way around. Qt has no "rm -rf", only "rmdir". See http://www.qtcentre.org/forum/p-recu...ostcount2.html.
May be QProcess with system specific call such as "rm" with "-R -d".
I guess windows has something similar too.
I m a beginner.Plz bear with me.but how to use QProcess to delete directory.
QProcessI haven't used QProcess with Qt4 yet, but I can remember having some problems with Qt3 with some shell commands and arguments for those commands.
However I can't see anything in the docs that points any such problems in Qt4, so it might work.
If QProcess wont help you, you can try also system specific calls such as system().
i didnt understand ...How this QProcess can be used to delete directory?
You will have to READ the QProcess doc for that.
Ask if there is anything specific you don't understand.
Using Qprocess to delete a directory is a dirty and non-portable method.
It is better to use the filesystem API in Qt to do it.