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.
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...
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
So, rmdir won't work in this case.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.
J-P Nurmi
May be QProcess with system specific call such as "rm" with "-R -d".
I guess windows has something similar too.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
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().
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
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.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
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.
Bookmarks