0

Hey,

I'm having a bit of trouble with progress bars and background workers and want to try and solve this with the simplest solution

What I am doing is reading the contents of a specific directory, I am then displaying in a list box all the folder names so that a user can click on them for further functionality

What I want to do, Is have a progress bar run whilst it is adding the folders to the list box but I am not sure how I can do it..

Is anyone able to help me out?

Thanks

Dan
_____
C# - Visual Studio 2010

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by NetDeveloper
0

Calculating how many files are in a directory structure (the max of the progress bar) would take pretty much just as much time as loading in the directory structure (which isn't very long with System.IO.Directory.GetDirectories()).

Basically the time it takes to count the directories is almost identical to loading all of the directory strings into an array. So unless you want this operation to take twice as long, I would just use a Marquee progress bar to let the user know the pc is busy. How are you loading in these directory names?

Edited by skatamatic: n/a

0

If there is a loop and you try to change ProgressBar value from this loop you have to check is your ProgressBar in the same thread of loop is working. (Use InvokeRequired and if it is true Invoke the method)

I recommend you dont change the value of a ProgressBar or any other controls within a thread. Instead rise an custom event.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.