プログラムでライブラリからドキュメントをダウンロードしようとするとエラー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のunotaurizedアクセスを取得します。あなたはそれが来るところのアイデアを持っていますか? ありがとう
解決
追加を試してみてください:
_WebClient.Credentials = CredentialCache.DefaultCredentials;
. 所属していません sharepoint.stackexchange