+ Reply to Thread
Results 1 to 10 of 10

Thread: Delete Directory

  1. #1
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Delete Directory

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,307
    Thanks
    20
    Thanked 376 Times in 370 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    ...

    Ok sorry, you wanted empty or not...
    Recommended off-line reading:
    The Foundations of Qt Development (ISBN: 1-59059-831-8)

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 537 Times in 520 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    I want to delete a directory empty or not empty in a easier way.
    So, rmdir won't work in this case.
    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.

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

    Default Re: Delete Directory

    Quote Originally Posted by AnithaRagupathy View Post
    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.
    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

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,307
    Thanks
    20
    Thanked 376 Times in 370 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    May be QProcess with system specific call such as "rm" with "-R -d".
    I guess windows has something similar too.
    Recommended off-line reading:
    The Foundations of Qt Development (ISBN: 1-59059-831-8)

  6. #6
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    I m a beginner.Plz bear with me.but how to use QProcess to delete directory.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,307
    Thanks
    20
    Thanked 376 Times in 370 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: 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().
    Recommended off-line reading:
    The Foundations of Qt Development (ISBN: 1-59059-831-8)

  8. #8
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    i didnt understand ...How this QProcess can be used to delete directory?

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,307
    Thanks
    20
    Thanked 376 Times in 370 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    You will have to READ the QProcess doc for that.
    Ask if there is anything specific you don't understand.
    Recommended off-line reading:
    The Foundations of Qt Development (ISBN: 1-59059-831-8)

  10. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 537 Times in 520 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete Directory

    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.

+ Reply to Thread

Similar Threads

  1. How do I get QMAKE_CLEAN to delete a directory?
    By Chuk in forum Qt Programming
    Replies: 5
    Last Post: 6th February 2012, 19:19
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. error in compiling qtopia.....
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 11th January 2007, 09:10
  4. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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