Sharepoint 2010 如何使用客户端对象模型sharepoint 2010从文档库中搜索文件

Sharepoint 2010 如何使用客户端对象模型sharepoint 2010从文档库中搜索文件,sharepoint-2010,sharepoint-clientobject,Sharepoint 2010,Sharepoint Clientobject,目前,我正在努力以编程方式启用搜索功能,以便使用客户端对象模型sharepoint 2010从文档库中搜索文件 你能帮我查一下密码吗 谢谢 KajalList List=clientcontext.Web.Lists.GetByTitle(ListName); clientcontext.Load(列表); clientcontext.ExecuteQuery(); FileCollection files=list.RootFolder.files; 加载(文件); clientcontext

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

你能帮我查一下密码吗

谢谢

Kajal

List List=clientcontext.Web.Lists.GetByTitle(ListName);
clientcontext.Load(列表);
clientcontext.ExecuteQuery();
FileCollection files=list.RootFolder.files;
加载(文件);
clientcontext.ExecuteQuery();
foreach(文件中的Microsoft.SharePoint.Client.File文件)
{
if(file.Name==txtSearch)
{
//你的逻辑
}
}
List List=clientcontext.Web.Lists.GetByTitle(ListName);
clientcontext.Load(列表);
clientcontext.ExecuteQuery();
FileCollection files=list.RootFolder.files;
加载(文件);
clientcontext.ExecuteQuery();
foreach(文件中的Microsoft.SharePoint.Client.File文件)
{
if(file.Name==txtSearch)
{
//你的逻辑
}
}
私有字符串搜索文档(字符串名称)
{
尝试
{
ClientContext=newclientcontext(“您的服务器”);
SP.List oList=clientContext.Web.Lists.GetByTitle(“您的文档”);
CamlQuery CamlQuery=新的CamlQuery();
camlQuery.ViewXml=@;
Microsoft.SharePoint.Client.ListItemCollection collListItem1=oList.GetItems(camlQuery);
Load(collListItem1,items=>items.Include(item=>item.DisplayName,item=>item[“Comments”]);
clientContext.ExecuteQuery();
foreach(collListItem1中的Microsoft.SharePoint.Client.ListItem oListItem1)
{
if(oListItem1.DisplayName==名称)
{
XXXXXXXXXXXXX
}
}
捕获(例外情况除外)
{
System.Windows.MessageBox.Show(例如Message,“异常”);
}
}
递归的搜索!

私有字符串搜索文档(字符串名称)
{
尝试
{
ClientContext=newclientcontext(“您的服务器”);
SP.List oList=clientContext.Web.Lists.GetByTitle(“您的文档”);
CamlQuery CamlQuery=新的CamlQuery();
camlQuery.ViewXml=@;
Microsoft.SharePoint.Client.ListItemCollection collListItem1=oList.GetItems(camlQuery);
Load(collListItem1,items=>items.Include(item=>item.DisplayName,item=>item[“Comments”]);
clientContext.ExecuteQuery();
foreach(collListItem1中的Microsoft.SharePoint.Client.ListItem oListItem1)
{
if(oListItem1.DisplayName==名称)
{
XXXXXXXXXXXXX
}
}
捕获(例外情况除外)
{
System.Windows.MessageBox.Show(例如Message,“异常”);
}
}
让我们来搜索吧

 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");
        }
    }