title: How To Get The Size Of A File (Hosted On A Web Server)?
body: <p>I am using the <code>WebClient</code> class to download an .exe file from a web server. Here is the code I am using to download the file:</p>
  
  <pre><code>WebClient webClient = new WebClient();    
  webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
  webClient.DownloadDataAsync(new Uri("http://www.blah.com/calc.exe")); 
  </code></pre>
  
  <p>My application has a ProgressBar which gets updated in the callback (<code>webClient_DownloadProgressChanged</code>):</p>
  
  <pre><code>private void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  {
      progressBar.Value = (int)e.BytesReceived;
  }
  </code></pre>
  
  <p>The problem I am having is I have to set the <code>Maximum</code> value for the progress bar dynamically. In other words I need to know the size of the file I am downloading <em>before</em> the download starts.</p>
  
  <p>Is there a way to get the size of a file (before downloading it) given it's uri?</p>