简体   繁体   English

从 Sharepoint 文档库下载

[英]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:我尝试过的事情:

  1. The linked post from this comment: https://sharepoint.stackexchange.com/a/105923此评论的链接帖子: https : //sharepoint.stackexchange.com/a/105923

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.显然那个套餐是付费套餐,而且很贵……我不能走那条路。

  1. Another answer: https://stackoverflow.com/a/53733630/2480558另一个答案: https : //stackoverflow.com/a/53733630/2480558

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'. 
  1. This solution: https://stackoverflow.com/a/15602003/2480558此解决方案: https : //stackoverflow.com/a/15602003/2480558

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 linepublic 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.

相关问题 C# 从 SharePoint 2013 文档库中检索文档列表 - C# Retrieve Document List From SharePoint 2013 Document Library 将文档从Windows Store App上载到SharePoint 2013文档库 - Uploading a document from Windows Store App to a SharePoint 2013 document library 如何将文档从Sharepoint文档库返回给用户? - How do I return a document from a Sharepoint Document library to the user? 如何代表其他用户关注 SharePoint 文档库 (SharePoint online) 中的文档 - How to Follow document from SharePoint document library (SharePoint online) on behalf of other users 从提供商托管的应用程序访问Sharepoint文档库项目 - access Sharepoint document library items from provider-hosted app 使用C#从Sharepoint 2007文档库中打开Excel文件 - Open excel file from Sharepoint 2007 Document Library with C# 如何将文档库/库从一个Sharepoint服务器复制到另一个 - How to copy document library/libraries from one Sharepoint server to another 从SharePoint文档库URL中提取文件夹/子文件夹名称 - Extracting folder/sub folder name from SharePoint document library URL 从SharePoint文档库下载而无需用户登录 - Download from SharePoint Document Library without having user login c#从SharePoint 2013中的文档库自动打印PDF - c# Auto print PDF from document library in SharePoint 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM