I am try to get the following file "GC_SELF_TEST.ppt" document from the following folder
When I run my code, it does not return any results. I'm quiet certain the problem is in my CamlQuery (I'm new to CSOM and CamlQuery).
I would just like to get this document for download purposes. Any help would Appreciated!
String site = "http://SPsite/";
ClientContext clientContext = new ClientContext(site);
clientContext.Credentials = new NetworkCredential("User", "Password", "Domain");
CamlQuery query = new CamlQuery();
query.ViewXml = "<View Scope='RecursiveAll'>
<Where>
<Eq>
<FieldRef Name='Name'/>
<Value Type='Text'>GC_SELF_TEST</Value>
</Eq>
</Where>
</View>";
Microsoft.SharePoint.Client.ListItemCollection docs = clientContext.Web.Lists.GetByTitle("Documents").GetItems(query);
clientContext.Load(docs);
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem doc in docs)
{
Console.WriteLine(doc.Id);
}
I also tried the following Query but no results:
"<View Scope='RecursiveAll'><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>GC_SELF_TEST.pptx</Value></Eq></Where></View>"
The internal name of the Name field is actually FileLeafRef
so your FieldRef
tag should look like this: <FieldRef Name='FileLeafRef'/>
I believe you'll also want to include the file extension in the value of your query.