0

我如何使用 sharepoint 对象模型以编程方式下载 documentSet 的代码片段将非常有帮助。

我要做的是-给定共享点站点,使用用户默认凭据登录-查找托管文件的文档库-将文件拉到本地计算机上

到目前为止我所做的,

using Microsoft.SharePoint.Client;

ClientContext cc = new ClientContext(ConfigurationManager.AppSettings["site"]);
            cc.Credentials = new NetworkCredential(username, pwd, domain);
            Web site = cc.Web;
            ListCollection collList = site.Lists;

            var oList = collList.GetByTitle("Document Set test");

            // Get the document set
            cc.Load(oList);
            cc.ExecuteQuery();

            // Get All views
            var views = oList.Views;
            cc.Load(views);
            cc.ExecuteQuery();

            // Get All documents
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = @"<Query>
                                   <ViewFields>
                                        <FieldRef Name='Title'/>
                                        <FieldRef Name='Display Name'/>
                                   </ViewFields>
                                   <Where>
                                      <Gt>
                                         <FieldRef Name='Created' />
                                         <Value IncludeTimeValue='TRUE' Type='DateTime'>1900-05-08T14:25:50Z</Value>
                                      </Gt>
                                   </Where>   
                                   <OrderBy>
                                         <FieldRef Name='Title' Ascending='True' />
                                   </OrderBy>                                    
                                </Query>";

            var docs = oList.GetItems(camlQuery);
            cc.Load(docs);
            cc.ExecuteQuery();

            Console.WriteLine(string.Format("{0} Models in the repository", docs.Count));

foreach(文档中的 var doc){

// 下载文档集中的文档 - 但是如何下载?

                Console.WriteLine(string.Format("{0} => {1} ", Environment.NewLine, doc["Title"]));
            }
            Console.WriteLine(Environment.NewLine);
4

1 回答 1

0

你会对这个Microsoft.SharePoint.Client.File.OpenBinaryDirect方法感兴趣。它返回FileInformation使内容可以通过Stream属性访问。您可以在此处、MSDN 页面Codeproject 文章中查看其他线程中的代码示例。

是的,Stackoverflow 上也有 SharePoint 开发人员 :-)

--- 费尔达

于 2012-04-07T18:36:20.593 回答