【发布时间】:2016-01-14 22:14:46
【问题描述】:
我正在尝试从以下文件夹中获取以下文件“GC_SELF_TEST.ppt”文档
当我运行我的代码时,它不会返回任何结果。 我很确定问题出在我的 CamlQuery 中(我是 CSOM 和 CamlQuery 的新手)。
我只想获取此文档以供下载。任何帮助将不胜感激!
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);
}
我也尝试了以下查询但没有结果:
"<View Scope='RecursiveAll'><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>GC_SELF_TEST.pptx</Value></Eq></Where></View>"
【问题讨论】:
标签: c# .net sharepoint csom sharepoint-clientobject