title: Show a ProgressBar while uploading a picture (Windows Form C#)
body: <p>I have a situation here. I have a picture box in windows form and i let user to browse a picture by using openfileupload control and after that i set selected picture into picture box. Here is my code:</p>
  
  <pre><code>namespace Employee_Card_Manager
  {
  public partial class Form1 : Form
  {
      string Chosen_File = "";
  
      public Form1()
      {
          InitializeComponent();
      }
  
      private void label1_Click(object sender, EventArgs e)
      {
  
      }
  
      private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
      {
  
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          selectpic.Title = "Browse Employee Picture!";
          selectpic.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
          selectpic.FileName = "";
          selectpic.Filter = "JPEG Images|*.jpg|GIF Images|*.gif|BITMAPS|*.bmp";
  
          if (selectpic.ShowDialog() != DialogResult.Cancel)
          {
              progressBar1.Enabled = true;
              Chosen_File = selectpic.FileName;
              pictureBox1.Image = Image.FromFile(Chosen_File);
              progressBar1.Enabled = false;
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It is working perfectly! I need to add some modification to this code so that when user browse a picture and presses Open button my application will show him a progress bar that this picture is being uploaded in mean time...
  I have found the following code to show a progress bar:</p>
  
  <pre><code>namespace ProgressBarSampleCSharp
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void CreateButton_Click(object sender, EventArgs e)
      {
          ProgressBar pBar = new ProgressBar();
          pBar.Location = new System.Drawing.Point(20, 20);
          pBar.Name = "progressBar1";
          pBar.Width = 200;
          pBar.Height = 30;
  
          //pBar.Dock = DockStyle.Bottom;
  
          pBar.Minimum = 0;
          pBar.Maximum = 100;
          pBar.Value = 70;
  
          Controls.Add(pBar);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But i have no idea how to fit this code into my class so that it will show progress bar in the mean time when picture is being uploaded!
  any ideas??</p>