I am trying to retrieve "Modified Date" and "Created Date" for folders when using GetFolderByServerRelativeUrl function, how can i do it?
I only able to get relativeUrl and folder Name out of it. below is what i did to retrieve the folder. Please help.
FolderCollection folderCollection = rootweb.GetFolderByServerRelativeUrl("/Shared Documents/test2").Folders;
spClientContext.Load(folderCollection);
foreach (Folder folder in folderCollection)
{
}
By retrieving and accessing the ListItemAllFields property of your Folders, you can access the created and modified dates as follows:
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"];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With