On Thu, 28 Jun 2007 12:16:55 -0700, <mc*********@interpolis.nlwrote:
I use a backgroundworker to get the total size of a homeshare (as it
is a bit time-consuming). Wat i would like to do, is show the
progress, but at start i don't know how much files/folders will come
up, so i dont't know how to feed the progressbar (i believe i need to
know the maximum # of files to get a representative progress bar?).
To show the user an accurate percentage completion, you need to know the
total amount of work. There's no way around that.
I don't know what it means to "get the total size of a homeshare" (what's
a "homeshare"?), but if that involves traversing a directory structure and
adding up file sizes or something like that, then yes...you can't
accurately determine the total amount of work without doing the whole
traversal. At which point you could have simply finished the work already.
That said, you can do some things to "fake it". One is to abandon the
idea of showing progress per se. Just show some indication of activity so
that the user knows you're doing _something_. Another option is to do a
quick preliminary traversal, enumerating the first one or two directory
levels, and then base your progress on that. The relative progress could
still wind up skewed if there is a huge difference in the work for each
directory near the top level, but it's about the best you can do in this
situation. In most cases, it would provide pretty good feedback to the
user.
Pete