CSOM Caml 查询无法找到文件 - SharePoint 2010

CSOM Caml Query Not able to find file - SharePoint 2010

我正在尝试从以下文件夹中获取以下文件 "GC_SELF_TEST.ppt" 文档

当我 运行 我的代码时,它没有 return 任何结果。 我很确定问题出在我的 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'/>

我相信您还希望在查询值中包含文件扩展名。