[英]CSOM Caml Query Not able to find file - SharePoint 2010
我嘗試從以下文件夾中獲取以下文件“ 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>"
名稱字段的內部名稱實際上是FileLeafRef
因此您的FieldRef
標記應如下所示: <FieldRef Name='FileLeafRef'/>
我相信您也希望在查詢的值中包含文件擴展名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.