【发布时间】:2014-05-15 16:39:22
【问题描述】:
string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);
我正在使用来自MSDN Web Site的代码
但我遇到了错误:403 禁止
有人可以帮我把这个工作吗?
【问题讨论】:
-
为什么你下载的文件是认证类型?您是否尝试将
myWebClient.Credentials = new NetworkCredential("User","Pass");设置为基本身份验证? -
尝试凭据后出现同样的错误!
标签: c# sharepoint office365