繁体   English   中英

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

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM