Progress Bar
hi, now i doing my project. i wan to ask how to do the progress bar when i loading the file ? after that, the content of the file will come out.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
FroglegPosted Jan 9, 2011, 5:24 PM
progressbar1.Value = 0;//reset progressbar1
int fileCount = Directory.GetFiles(sourceDir).Length;
progressbar1.maximum = fileCount;// set progressbar1 maximum value to equal number of files
foreach (string file in Directory.GetFiles(sourceDir))
{
string name = Path.GetFileName(file);
string dest = Path.Combine(destinationDir, name);
File.Copy(file, dest, true);//copy files - overwrite = true
progressbar1.PerformStep();//increment progressbar by 1 for each copied file
}
Kevin AungPosted Jan 9, 2011, 2:07 PM
ex:
myProgressBar.Value = 40;