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. Progress bar implementation for recursive directory deletion

Progress bar implementation for recursive directory deletion

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • C Offline
    C Offline
    Chintoo723
    wrote on last edited by
    #1

    I delete all the files/directories in a directory recursively in my application, and since that takes time I want to show a progress bar. To implement the progress bar I first need to scan the directory to know how many files are there and then in the second pass I progress the bar appropriately every time I delete a file/directory. Is there a way to quickly find out how many files, including those in the sub directories, are there in a directory? If there is a way other than explicitly walking down the directory using FindFirstFile/FindNextFile, I would like to know, since this is causing the time to delete almost 1.5 times the time spent. thanks!

    D V 2 Replies Last reply
    0
    • C Chintoo723

      I delete all the files/directories in a directory recursively in my application, and since that takes time I want to show a progress bar. To implement the progress bar I first need to scan the directory to know how many files are there and then in the second pass I progress the bar appropriately every time I delete a file/directory. Is there a way to quickly find out how many files, including those in the sub directories, are there in a directory? If there is a way other than explicitly walking down the directory using FindFirstFile/FindNextFile, I would like to know, since this is causing the time to delete almost 1.5 times the time spent. thanks!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      There is no need to make two passes. While counting, add the list of files and folders to an array of some sort and delete them from there. You can always use SHFileOperation(). It uses recursion and a progress bar.


      "The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb

      1 Reply Last reply
      0
      • C Chintoo723

        I delete all the files/directories in a directory recursively in my application, and since that takes time I want to show a progress bar. To implement the progress bar I first need to scan the directory to know how many files are there and then in the second pass I progress the bar appropriately every time I delete a file/directory. Is there a way to quickly find out how many files, including those in the sub directories, are there in a directory? If there is a way other than explicitly walking down the directory using FindFirstFile/FindNextFile, I would like to know, since this is causing the time to delete almost 1.5 times the time spent. thanks!

        V Offline
        V Offline
        vallikumar
        wrote on last edited by
        #3

        Hi pls send your mail id to dingudikka@yahoo.com I will send the sample source code to count the no:of files and folders in a drive regards Vallikumar A

        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