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