【问题标题】:How to search file from a document library using client object model sharepoint 2010如何使用客户端对象模型 sharepoint 2010 从文档库中搜索文件
【发布时间】:2012-07-05 14:51:40
【问题描述】:

目前,我正在努力以编程方式启用搜索功能,以便使用客户端对象模型 sharepoint 2010 从文档库中搜索文件,

你能帮我写代码吗

谢谢

卡哈尔

【问题讨论】:

    标签: sharepoint-2010 sharepoint-clientobject


    【解决方案1】:
    List list = clientcontext.Web.Lists.GetByTitle(ListName);
    clientcontext.Load(list);
    clientcontext.ExecuteQuery();
    
    FileCollection files = list.RootFolder.Files;
    clientcontext.Load(files);
    clientcontext.ExecuteQuery();
    foreach (Microsoft.SharePoint.Client.File file in files)
    {
        if(file.Name == txtSearch)
        {
            // your logic
        }
    
    }
    

    【讨论】:

      【解决方案2】:
       private string searchDoc(string name)
          {
              try
              {
                  ClientContext clientContext = new ClientContext("YOUR SERVER");
                  SP.List oList = clientContext.Web.Lists.GetByTitle("YOUR DOC");
                  CamlQuery camlQuery = new CamlQuery();
                  camlQuery.ViewXml = @"<View Scope='Recursive'/>";
                  Microsoft.SharePoint.Client.ListItemCollection collListItem1 = oList.GetItems(camlQuery);
                  clientContext.Load(collListItem1, items => items.Include(item => item.DisplayName, item => item["Comments"]));
                  clientContext.ExecuteQuery();
                  foreach (Microsoft.SharePoint.Client.ListItem oListItem1 in collListItem1)
                  {
                       if (oListItem1.DisplayName == name)
                       {
                           XXXXXXXXXXXXXX
                       }
                  }
      
              catch (Exception ex)
              {
                  System.Windows.MessageBox.Show(ex.Message, "Exception");
              }
          }
      

      递归的搜索!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-03-04
        • 2011-07-15
        • 1970-01-01
        • 2011-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多