title: C# Download an image from URL
body: <p>I use a website to get stats on wifi usage. The website creates an image of a graph representation of the data. The way it does this is by the user, setting a date. So for example, lets say it was last months statistics. The website generates a URL which is then sent to the server and the server returns an image. an examples of the link is like this:</p>
  
  <p><a href="https://www.example.com/graph/daily_usage?time_from=2015-06-01+00%3A00%3A00+%2B0100&amp;time_to=2015-06-30+23%3A59%3A59+%2B0100&amp;tsp=1436519988" rel="nofollow">https://www.example.com/graph/daily_usage?time_from=2015-06-01+00%3A00%3A00+%2B0100&amp;time_to=2015-06-30+23%3A59%3A59+%2B0100&amp;tsp=1436519988</a></p>
  
  <p>The problem is, I am making a third party program that will download this image to be used in my program. However, I cannot use the file. It is as if the file is corrupt or something. I have tried a few methods but maybe someone can suggest a different approach. <strong>Basically, how do I download an image that is generated by a server from a URL link?</strong></p>
  
  <p><strong>P.S.</strong></p>
  
  <p>Just noticed that if I download the file by right clicking through a browser and save, the image downloads with a size of 17.something kilobytes. But if I use the WebClient method to download the image, it only downloads 1.5kb. Why would that be? Seems like the WebClient method does not download completely. </p>
  
  <p><strong>Currently my code</strong></p>
  
  <pre><code>if (hrefAtt == "Usage Graph")
  {
      string url = element.getAttribute("src");
      WebClient client = new WebClient();
      client.DownloadFile(url, tempFolderPath + "\\" + currentAcc + "_UsageSummary.png");
      wd.AddImagesToDoc(tempFolderPath + "\\" + currentAcc + "_UsageSummary.png");
      wd.SaveDocument();
  }
  </code></pre>
  
  <p>TempFolderPath is my desktop\TempFolder\</p>
  
  <p><strong>UPDATE</strong>
  Out of random, I decided to see the raw data of the file with notepad and interestingly, the image data was actually a copy of the websites homepage html code, not the raw data of the image :S how does that make sense?</p>