[英]download image from SharePoint Online using C#
I want to download Images from SharePoint Online site . 我想从SharePoint Online网站下载图像。 Here is my code it will give webclient Exception.
这是我的代码,它将给webclient异常。
var securedPassword = new SecureString();
foreach (var c in password.ToCharArray()) securedPassword.AppendChar(c);
var credentials = new SharePointOnlineCredentials(username, securedPassword);
DownloadFile(url, credentials, "https://damasjewellery.sharepoint.com/:i:/r/Products/Catalogue%20Images/BDR-001-NA-RG-X-0.JPG?csf=1&e=FclkOs");
DownloadFile Method Contains Webclient Object And Its DownloadFIle method. DownloadFile方法包含Webclient对象及其DownloadFIle方法。 When I pass Url and path of Particular Images It will Give me an exception .
当我通过“网址”和“特殊图像的路径”时,它将给我一个例外。
using (var client = new WebClient())
{
client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
client.Headers.Add("User-Agent: Other");
client.Credentials = credentials;
client.DownloadFile(webUrl, fileRelativeUrl);
}
A WebClient Exception usually means there's some kind of connection issue. WebClient异常通常意味着存在某种连接问题。 Either the server returned a 404, the server timed out, there's no internet connection, or you're having a permissions issue.
服务器返回404,服务器超时,没有互联网连接,或者您遇到权限问题。
*Edit: Realized the exception being thrown was already in the question. *编辑:意识到问题中已经抛出了异常。
Try swapping url to uri. 尝试将网址交换为uri。
public void DownloadFile(
Uri address,
string fileName
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.