0

Possible Duplicate:
updating progress bar during a file search

I'm using FindFirstFile and FindNextFile recursively to search for a file by searching 20 levels deep.
How would I go about adding a progress bar? To show the progress of the search?

I want something similar to the progress bar in explorer when you search for a file.

But how would I figure out how many total files I have to search through to figure out the % completed?

Community
  • 1
  • 1
Josh
  • 6,046
  • 11
  • 52
  • 83
  • Check my (C#) answer [here](http://stackoverflow.com/questions/12042159/updating-progress-bar-during-a-file-search/12043088#12043088). The principle is the same. – ssube Aug 30 '12 at 21:42

1 Answers1

1

If the only thing you do is searching for a file then the only thing that comes to my mind is to calculate average amount of files per directory. I guess you have much more files than directories, so while you progress through directories you divide 100% by bigger and bigger number. Of course you may see progress stalling or even goign back.

In case you do something for each of the file, I would suggest running a separate thread that would be traversing your file system while other thread would be doing stuff on each of the found file. When the traversing thread counts all the files, and maybe even their total sizes, your progress will become most accurate (of course you will have some problems on an alive file system that may be adding or removing files in the meantime.)

Grzegorz
  • 3,207
  • 3
  • 20
  • 43