gpt4 book ai didi

c# - Sharepoint 客户端 GetFolderByServerRelativeUrl 文件夹修改日期

转载 作者:行者123 更新时间:2023-12-01 14:04:29 25 4
gpt4 key购买 nike

我在使用 GetFolderByServerRelativeUrl 函数时试图检索文件夹的“修改日期”和“创建日期”,我该怎么做?

我只能从中获取 relativeUrl 和文件夹名称。以下是我为检索文件夹所做的工作。请帮忙。

FolderCollection folderCollection = rootweb.GetFolderByServerRelativeUrl("/Shared Documents/test2").Folders;
spClientContext.Load(folderCollection);

foreach (Folder folder in folderCollection)
{

}

最佳答案

通过检索和访问 ListItemAllFields Folder 的属性,您可以按如下方式访问创建和修改日期:

using (ClientContext spClientContext = new ClientContext("http://whatever"))
{
var rootweb = spClientContext.Web;

FolderCollection folderCollection =
rootweb.GetFolderByServerRelativeUrl("/Shared Documents/test2").Folders;

// Don't just load the folder collection, but the property on each folder too
spClientContext.Load(folderCollection, fs => fs.Include(f => f.ListItemAllFields));

// Actually fetch the data
spClientContext.ExecuteQuery();

foreach (Folder folder in folderCollection)
{
// This property is now populated
var item = folder.ListItemAllFields;

// This is where the dates you want are stored
var created = (DateTime)item["Created"];
var modified = (DateTime)item["Modified"];
}
}

关于c# - Sharepoint 客户端 GetFolderByServerRelativeUrl 文件夹修改日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16931355/

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