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
I'm not sure the correct syntax to use for this. Here is my code below.
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;
Path.GetFileNamedoes what you think it does.