title: Calculating total bytes to download using WebClient()
body: <p>The variable 'totalBytes' is constantly at -1 so I cannot calculate/update the progress bar correctly, why would this be happening?</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      WebClient client = new WebClient();
      client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
      client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
      client.DownloadFileAsync(new Uri("http://example.com/test.mp3"), @"E:\Test.mp3");
  }
  
  private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  {
      double bytesIn = double.Parse(e.BytesReceived.ToString());
      label1.Text = Convert.ToString(bytesIn);
  
      double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); //stays at -1
      label2.Text = Convert.ToString(totalBytes);
  
      double percentage = bytesIn / totalBytes * 100;
      label3.Text = Convert.ToString(percentage);
  
      progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
  }
  </code></pre>