title: WebClient Download file got error: Object reference not set to an instance of an object
body: <pre><code>WebClient ws = new WebClient();
  ws.Credentials = new System.Net.NetworkCredential(username, password, domain);
   ws.DownloadFile("https://xxxx.xxxx.com/xxxx.xml", @"C:\Windows\TEMP\Downloaded.xml");
  </code></pre>
  
  <p>I got error 'Object reference not set to an instance of an object'.
  Anyone know why?</p>
  
  <p>If I copy the "https://xxxx.xxxx.com/xxxx.xml" to browser, it can download and save to "C:\Windows\TEMP\Downloaded.xml", but my program can not, only throw the error.</p>
  
  <p>Previously I use the same code successfully download the file, but that was another site with 'http'. Not sure whether it's the cause of the problem.</p>