title: ASP.NET Download Image file from URL with querystring
body: <p>I'm trying to download an image from a URL. The URL has a security key appended to the end and I keep getting the following error:
  System.Net.WebException: An exception occurred during a WebClient request. ---> System.ArgumentException: Illegal characters in path</p>
  
  <p>I'm not sure the correct syntax to use for this. Here is my code below.</p>
  
  <pre><code>string remoteImgPath = "https://mysource.com/2012-08-01/Images/front/y/123456789.jpg?api_key=RgTYUSXe7783u45sRR";
  string fileName = Path.GetFileName(remoteImgPath);
  string localPath = AppDomain.CurrentDomain.BaseDirectory + "LocalFolder\\Images\\Originals\\" + fileName;
  WebClient webClient = new WebClient();
  webClient.DownloadFile(remoteImgPath, localPath);
  return localPath;
  </code></pre>