从文档库sharepoint 2010获取所有文件夹和子文件夹中的所有文档

时间:2012-03-27 06:12:01

标签: sharepoint-2010 caml

我想使用客户端对象模型将文件夹中的所有文档检索到它的子文件夹等。请帮助我。

1 个答案:

答案 0 :(得分:3)

我找到了解决方案

 ClientContext clientContext =
    new ClientContext("http://Servername/");
    List sharedDocumentsList = clientContext.Web.Lists.GetByTitle("Shared Documents");
    CamlQuery camlQuery = new CamlQuery();
   camlQuery.ViewXml = @"<View Scope='Recursive'><Query><Where><Eq><FieldRef Name='FSObjType' /><Value Type='Lookup'>0</Value></Eq></Where></Query></View>"


    ClientOM.ListItemCollection listItems =
        sharedDocumentsList.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    foreach (var item in listItems)
    {
       // get all document here
    }
相关问题