尝试以编程方式从图书馆下载文档时出错401
-
09-12-2019 - |
题
我正在尝试使用此代码下载文档:
using (Impersonator impersonator = new Impersonator())
{
siteURL += "?NoRedirect=true";
System.Net.WebClient _WebClient = new System.Net.WebClient();
// Downloads the resource with the specified URI to a local file.
_WebClient.DownloadFile(siteURL, saveName);
}
.
但是我收到错误401未脱脚访问。你有什么想法来自哪里? 谢谢
解决方案
尝试添加:
_WebClient.Credentials = CredentialCache.DefaultCredentials;
.