Results 1 to 13 of 13

Thread: remove directory empty or not empty

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    42
    Thanked 1 Time in 1 Post

    Default Re: remove directory empty or not empty

    Hi

    No i didnt get a error message from MINGW

    With following code the for loop never end.
    Why??

    Qt Code:
    1. void Manage::removeArtistDirectory(const QString &artistDirectory)
    2. {
    3.  
    4. QFileInfo fileInfo(artistDirectory);
    5. if(fileInfo.isDir())
    6. {
    7. QDir dir(artistDirectory);
    8. QStringList fileList = dir.entryList();
    9. for(int i = 0; i < fileList.count(); ++i)
    10. {
    11. QMessageBox::information(this,"",fileList.at(i));
    12. removeArtistDirectory(fileList.at(i));
    13. }
    14. dir.rmdir(artistDirectory);
    15. }
    16. else
    17. {
    18. QFile::remove(artistDirectory);
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: remove directory empty or not empty

    Try excluding "."'s and ".."'s:
    Qt Code:
    1. QStringList fileList = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn 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.