file - ProgressBar when Scanning a Hard Drive -


Therefore, I am doing a simple scan to get a list of all the folders on the hard drive (c: \ windows And C: \ windows \ system32 are considered separate entries). If I want to provide a progress bar for this 1-2 minute task, how would I do this? That is, I know how to make progress bar, but it is not certain how it is decided how much work is done for it.

EDIT: Note that executing a prescan is not a solution, because it is scanned only to get a list of folders and a propane will only take longer.

The code sample is below it takes less than 2 minutes to be clean on my system, but less than 10 seconds to run 2 times due to disk access caching. I have made variations on this, which are stack based on recurrence.

I have found that a mechanism is probably not 100% reliable, but faster than my scan, "DIREES / S / AB / b" in my program and in the new line, It works like magic which works better to scan my HD than my program, but I do not know what the magic is.

  class program {static zero recurs (string pause) {directoryInfo f = new directory info (pos); Try in {foreach (directory.info X) f.GetDirectories ("*")) {recurse (x.FullName); }} Hold (exception) {}} static zero main (string [] args) {recurse ("c: \\"); }}  

If you can not redistribute the directory structure, because long time To get the job done in the first place, the best you can do is to estimate how many folders are. seriously.

Perhaps you can use an algorithm based on past history (like in the past I did this, there were 150 directories in the total, when there were 10 top level directories, so a good estimate is 15 times the current Number of top-level directories).

Another way to tell the user something will take some time (to use the countdown timer) even if you have guessed that it will actually take a much longer time. (When it's actually 5 minutes of 3 minutes of action), at least the user knows how long it will take. And when they are finished fast, they will be happy because they will be told this. Of course, of course, if you make a mistake on the other side, that is, if you feel that it takes a little longer time then it will happen. Then they are sitting there waiting for something to finish (in their mind) should have already ended.


Comments