SharePoint - 客户端对象模型 - 获取子文件夹项目
每个'listItem'包含项目,如何获取它们?我尝试了一段时间但只失败了,
帮忙,谢谢
camlQuery来自网络上的一些测试和示例,没有帮助(有很多变化)
ClientContext clientContext = new ClientContext("http://xxx.xxx.com");
List list = clientContext.Web.Lists.GetById(new Guid("{F91A0F26-2826-4B3B-AF30-ED7DE4494C7B}"));
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<queryOptions><QueryOptions><ViewAttributes Scope='RecursiveAll'/><Folder></Folder></QueryOptions></queryOptions>";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (ListItem listItem in listItems)
{
each lisItem has children/items , how to get them?!
}
each 'listItem' contains items , how to get them? I'm trying for a while but only fail ,
help , thanks
the camlQuery is from some tests and examples from the web , didn't help ( had many changes)
ClientContext clientContext = new ClientContext("http://xxx.xxx.com");
List list = clientContext.Web.Lists.GetById(new Guid("{F91A0F26-2826-4B3B-AF30-ED7DE4494C7B}"));
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<queryOptions><QueryOptions><ViewAttributes Scope='RecursiveAll'/><Folder></Folder></QueryOptions></queryOptions>";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (ListItem listItem in listItems)
{
each lisItem has children/items , how to get them?!
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经找到答案了,感谢帮助者...:)
Items
是我创建的对象。要获取“folderServerRelativeUrl”值,您可以从
(string)listItem ["FileRef"]
当您从上面的 foreach 浏览文件夹时I have found the answer , thanks for the helpers... :)
Items
is my object I created.to get "folderServerRelativeUrl" value, you can get it from
(string)listItem ["FileRef"]
when you go over the folders from above foreach获取列表文件夹所有项目的另一种方法:
Another way to get all items of list folders:
谢谢你的回答。只是为了让您知道folderServerRelativeUrl 变量应该来自根Url(
http://server
除外)。我确实在文档中心内有一个名为“供应商”的列表。即,siteUrl 为http://server/documentcenter
,列表名称为 Vendors。我必须传递“/documentcenter/Vendors/...”作为我的folderServerRelativeUrl。但那没关系。我仍然很感激你。Stack Overflow 的朋友们,很遗憾我无法在他的答案下添加评论。我必须提交此评论作为答案。如果可以以不同的方式完成此操作,请帮助我。我不想编辑他的答案。
〜沙敏
Thank you for this great answer. Just to let you know that the folderServerRelativeUrl variable should be from the root Url (except the
http://server
). I did have a list named "Vendors" inside documentcenter. That is, siteUrl ishttp://server/documentcenter
and the list name is Vendors. I had to pass "/documentcenter/Vendors/..." as my folderServerRelativeUrl. But that is OK. I am still grateful to you.Stack Overflow folks, it is so sad that I could not add a comment underneath his answer. I had to submit this comment as an answer. Help me if this could be done in a different way. I do not want to edit his answer.
~Sharmin