我正在尝试使用 webclient 获取 pdf 文件数据,但它引发了 “远程服务器返回错误:(404)未找到”的异常。
以下是错误详情:
System.Net.WebException 被捕获
Message=远程服务器返回错误:(404) 未找到。源=系统
StackTrace:在 System.Net.WebClient.DownloadData(Uri 地址)在 System.Net.WebClient.DownloadData(字符串地址)的 System.Net.WebClient.DownloadDataInternal(Uri 地址,WebRequest& 请求)
错误状态:System.Net.WebExceptionStatus.ProtocolError
这是我用来下载数据的代码片段:
try{
WebClient cl = new WebClient();
byte[] data = cl.DownloadData(URL);
}
catch(exception ex){
}
任何想法??