Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to remove a directory

How to remove a directory

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nbugalia
    wrote on last edited by
    #1

    How to remove a directory and it's sub directory/files? Api RemoveDirectory only operates on empty directories.

    L R H T 4 Replies Last reply
    0
    • N nbugalia

      How to remove a directory and it's sub directory/files? Api RemoveDirectory only operates on empty directories.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to write a recursive function to walk down the folder tree and start deleting things from the bottom up. For a given directory enumerate the contents, for each sub directory call your directory delete function again and then delete the directory when it returns

      1 Reply Last reply
      0
      • N nbugalia

        How to remove a directory and it's sub directory/files? Api RemoveDirectory only operates on empty directories.

        R Offline
        R Offline
        Roger Broomfield
        wrote on last edited by
        #3

        You could try experimenting with SHFileOperation() setting the wFunc member to FO_DELETE and NOT including FOF_NORECURSION in the fFlags member. I have used it to delete all files in a folder in one operation but havent actually tried the recursive delete that is implied by the FOF_NORECURSION flag.

        1 Reply Last reply
        0
        • N nbugalia

          How to remove a directory and it's sub directory/files? Api RemoveDirectory only operates on empty directories.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Or see _rmdir.

          R 1 Reply Last reply
          0
          • N nbugalia

            How to remove a directory and it's sub directory/files? Api RemoveDirectory only operates on empty directories.

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            http://www.codeproject.com/shell/cshellfileop.asp\[[^](http://www.codeproject.com/shell/cshellfileop.asp "New Window")]

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
            Never mind - my own stupidity is the source of every "problem" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

            1 Reply Last reply
            0
            • H Hamid Taebi

              Or see _rmdir.

              R Offline
              R Offline
              Roger Broomfield
              wrote on last edited by
              #6

              Please Note: _rmdir The directory must be empty, and it must not be the current working directory or the root directory.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups