1

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

你能帮我写代码吗

谢谢

卡哈尔

4

2 回答 2

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
    }

}
于 2012-07-20T11:06:37.267 回答
0
 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");
        }
    }

递归的搜索!

于 2012-08-14T09:51:53.897 回答