Windows Develop Bookmark and Share   
 index > Windows Forms General > Progerss bar
 

Progerss bar

Hi I am trying to have a progress bar showing the user how much is done. Actually I am uploading a file to the server. I have created a method
public void uploadToServer(string fileName)
{
//...
}
I want to show a progress bar how much is done... or start incrementing the progress bar till it completes the method uploadToServer(). I have never used progress bar. Please help me how I can achieve this.

Thank you so much.
Ravi Santha  Saturday, January 13, 2007 8:07 AM
I think you can use the BackgroundWorker to perform such long time operation as uploading. And the BackgroundWorker has an ability to report progress.

...
int progress = (int) ((float)uploaded / (float)fileSize * 100);
bw.ReportProgress(progress);
...

and here is event handler:
private void bckgrndWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.myProgressBar.Value = e.ProgressPercentage;
}
eugene7_11  Saturday, January 13, 2007 8:53 AM

Hi RaviSantha, I think you can add one timer in your form

then using the timer to refresh the upload status

Bob zhu - SJTU  Tuesday, January 16, 2007 5:06 AM
In this article there are many demo of upload file to server,I am sure this will help you .
Gavin Jin - MSFT  Tuesday, January 16, 2007 7:33 AM

You can use google to search for other answers

Custom Search

More Threads

• Crystal Reports with .NET
• Help with mshtml - Deploying Software
• Fast PictureBox Panning?
• textbox formatting
• I can't get Timer to work...
• DataGridview
• display and update the content of atable in database(MS Access)
• Regarding changing Font size and the application getting crashed.
• Auto Hide Contents in C#
• Detect if a form is obscured by another form