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
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
}
}
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");
}
}
Recursive's search!