Results 1 to 13 of 13

Thread: remove directory empty or not empty

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: remove directory empty or not empty

    You will need to write a recursive function to do this.

    Something like this

    Qt Code:
    1. void remove(const QString &path)
    2. {
    3. QFileInfo fileInfo(path);
    4. if(fileInfo.isDir()){
    5. QDir dir(path);
    6. QStringList fileList = dir.entryList();
    7. for(int i = 0; i < fileList.count(); ++i){
    8. remove(fileList.at(i));
    9. }
    10. rmpath(path);
    11. }
    12. else{
    13. QFile::remove(path);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to munna for this useful post:

    raphaelf (27th October 2006)

Similar Threads

  1. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54
  2. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.