[英]Downloading from Sharepoint Document Library
Goal: Download documents from a Sharepoint 2010 Document Library using C#目标:使用 C# 从 Sharepoint 2010 文档库下载文档
I've searched and found many questions/resources regarding how to download documents to a local disk from a Sharepoint Document Library.我搜索并发现了许多关于如何从 Sharepoint 文档库将文档下载到本地磁盘的问题/资源。 I've so far been unable to successfully implement a solution.
到目前为止,我一直无法成功实施解决方案。
For the sake of discussion, my document library is located at the following link: http://server.domain.com/sites/CompanyLocation/dprtmnts/DepartmentName/MyLibraryName/Forms/AllItems.aspx为便于讨论,我的文档库位于以下链接: http : //server.domain.com/sites/CompanyLocation/dprtmnts/DepartmentName/MyLibraryName/Forms/AllItems.aspx
Within this document library are two folders, each containing a number of documents.在此文档库中有两个文件夹,每个文件夹都包含多个文档。 I desire to retrieve a list of these documents (in each folder) and have the ability to download/open a document on command.
我希望检索这些文档的列表(在每个文件夹中),并且能够根据命令下载/打开文档。
Things I've tried:我尝试过的事情:
The linked post ( https://stackoverflow.com/a/21056425/2480558 ) offers a solution for both downloading and uploading.链接的帖子 ( https://stackoverflow.com/a/21056425/2480558 ) 提供了下载和上传的解决方案。 I only need to download, so I tried that.
我只需要下载,所以我试过了。 This solution gives me a Microsoft.SharePoint.Client.ServerObjectNullReferenceException.
这个解决方案给了我一个 Microsoft.SharePoint.Client.ServerObjectNullReferenceException。 There are no instructions on what the url, listTitle, or listItemId need to be, so I'm probably doing something wrong... it doesn't appear to be getting any files.
没有关于 url、listTitle 或 listItemId 需要什么的说明,所以我可能做错了什么......它似乎没有得到任何文件。
I also tried the first blog post on that answer that points to using a package from bendsoft.我还尝试了关于该答案的第一篇博客文章,该文章指出使用了来自 Bendsoft 的软件包。 Apparently that package is a paid package, and it's quite expensive.. I can't go that route.
显然那个套餐是付费套餐,而且很贵……我不能走那条路。
This gives me the following exception: (actual server edited out of exception)这给了我以下异常:(实际服务器编辑出异常)
Microsoft.SharePoint.Client.ClientRequestException: 'The IDCRL response header from server 'http://server.domain.com/' is not valid. The response header value is 'NTLM'. The response status code is 'Unauthorized'.
Honestly, I don't even remember why that one didn't work.老实说,我什至不记得为什么那个不起作用。
If anyone has something that might help me get on the right path... I'm not familiar with making web requests and web authorization, or anything of that nature.如果有人有什么可以帮助我走上正确道路的东西......我不熟悉发出网络请求和网络授权,或任何类似的事情。
If you use the example that you found at https://stackoverflow.com/a/53733630/2480558 , but you have to adapt it for your local SharePoint server, since that code is logging in to SharePoint Online.如果您使用在https://stackoverflow.com/a/53733630/2480558 上找到的示例,但您必须针对您的本地 SharePoint 服务器对其进行调整,因为该代码正在登录 SharePoint Online。
In the public void Connect()
definition, replace the line在
public void Connect()
定义中,替换行clientContext.Credentials = new SharePointOnlineCredentials(UserName, securePassword);
with this instead:用这个代替:
clientContext.Credentials = new NetworkCredential(UserName, securePassword, "putYourADDomainNameHere");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.