我正在尝试使用此代码下载文档:

 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;
.

许可以下: CC-BY-SA归因
scroll top