gpt4 book ai didi

sharepoint-2010 - SharePoint - 客户端对象模型 - 获取子文件夹项目

转载 作者:行者123 更新时间:2023-12-04 07:01:35 26 4
gpt4 key购买 nike

每个“listItem”都包含 items ,如何获取它们?我尝试了一段时间,但只是失败了,

帮助,谢谢

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?!

}

最佳答案

我找到了答案,感谢帮助者... :)Items是我创建的对象。
要获得“folderServerRelativeUrl”值,您可以从(string)listItem ["FileRef"]当您从 foreach 上方查看文件夹时

  public Items GetFolderItems(string folderServerRelativeUrl, List list, ClientContext clientContext)
{
try
{
var result = new Items(); <-- my class
var query = new CamlQuery();

query.FolderServerRelativeUrl = folderServerRelativeUrl;

query.ViewXml = "<View Scope=\"RecursiveAll\"> " +
"<Query>" +
"<Where>" +
"<Eq>" +
"<FieldRef Name=\"FileDirRef\" />" +
"<Value Type=\"Text\">" + folderServerRelativeUrl + "</Value>" +
"</Eq>" +
"</Where>" +
"</Query>" +
"</View>";

var folderItems = list.GetItems(query);
clientContext.Load(folderItems);
clientContext.ExecuteQuery();

foreach (ListItem item in folderItems)
{
// item[ "..." ];
}

return result;
}
catch (Exception)
{
return null;
}
}

关于sharepoint-2010 - SharePoint - 客户端对象模型 - 获取子文件夹项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9350347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com