How to search file from a document library using client object model sharepoint 2010

sharepoint-2010sharepoint-clientobject

At the moment i am struggling to programatically enable the search functionality to search file from a document library using client object model sharepoint 2010,

Can you please help me with the code

Thanks

Kajal

Best Answer

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
    }

}
Related Topic