Question

I'm trying to download a document with this code :

 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);
 }

But i get an error 401 unothaurized access. Do you have any idea where it come froms ? Thanks

Was it helpful?

Solution

Try adding:

_WebClient.Credentials = CredentialCache.DefaultCredentials;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top