public void DownloadFileFromSite(string siteURL, string saveName )
{ try { System.Net.WebClient _WebClient = new System.Net.WebClient(); // Downloads the resource with the specified URI to a local file. _WebClient.DownloadFile(siteURL, saveName);
} catch (Exception _Exception) { // Error MessageBox.Show("Error In Downloading"); } }
this returns 401 unauthorised
ReplyDeletehttp://stackoverflow.com/questions/1443617/407-authentication-required-no-challenge-sent/1482442#1482442
ReplyDeletehttp://blogs.realdolmen.com/experts/2010/11/08/sharepoint-401-unauthorized-downloading-infopath-file-with-webclient-downloadfile/
ReplyDeletehttp://stackoverflow.com/questions/8609211/download-file-from-given-url
ReplyDeleteprivate static bool DownloadFileFromSite(string siteURL, string saveName)
ReplyDelete{
try
{
// Downloads the resource with the specified URI to a local file
System.Net.WebClient _WebClient = new System.Net.WebClient();
_WebClient.UseDefaultCredentials = true;
_WebClient.DownloadFile(siteURL, saveName);
}
catch (Exception ex)
{
Console.WriteLine("Error downloading latest spreadsheet from Sharepoint:" + ex.Message + ex.StackTrace);
return false;
}
return true;
}