我正在尝试从URL下载图像。该URL末尾附有一个安全密钥,但我一直收到以下错误:
System.Net.WebException:WebClient请求期间发生异常。 ---> System.ArgumentException:路径中包含非法字符
我不确定要使用哪种正确的语法。以下是我的代码。
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.GetFileName
不是你想象中的那样。 - Brian Driscoll