Jul 13 2020 02:18 AM
Have a folder in a SharePoint Document Library that has 3 files in it.
When I delete the folder, I'm getting one change returned in the GetChanges function. It is a ChangeItem related to the deleted folder, but I don't get any changes returned for the files in the folder.
Is this correct?
I'm sure in the past I used to get the files that have been deleted too, but unable to confirm.
This is the code I'm using currently.
Have tried at different scopes to (i.e. changes at Library, Root Folder etc.)
using (var authenticationManager = new AuthenticationManager())
using (var context = authenticationManager.GetContext(siteUri))
{
var site = context.Site;
context.Load(site);
var query = new ChangeQuery(true, true)
{
File = true,
Item = true,
Folder = true,
RecursiveAll = true,
DeleteObject = true,
Rename = false,
Add = false,
Update = false,
Site = false,
Web = false,
List = false,
User = false,
View = false,
SystemUpdate = false,
};
var changes = site.GetChanges(query);
context.Load(changes);
await context.ExecuteQueryAsync();
foreach (Change change in changes)
{
if (change is Microsoft.SharePoint.Client.ChangeItem)
{
ChangeItem ci = change as ChangeItem;
Console.WriteLine($"Item {ci.ItemId.ToString()}: {ci.ChangeType.ToString()}");
}
if (change is Microsoft.SharePoint.Client.ChangeFolder)
{
ChangeFolder cf = change as ChangeFolder;
Console.WriteLine($"Folder {cf.UniqueId.ToString()}: {cf.ChangeType.ToString()}");
}
if (change is Microsoft.SharePoint.Client.ChangeFile)
{
ChangeFile cf = change as ChangeFile;
Console.WriteLine($"Folder {cf.UniqueId.ToString()}: {cf.ChangeType.ToString()}");
}
}
}
Sep 28 2022 12:58 AM
Hi
How to get the filename of deleted file in sharepoint.
if (change is ChangeItem)
{
ListItem modifiedItem = changeList.GetItemById((change as ChangeItem).ItemId);
cxt.Load(modifiedItem);
cxt.ExecuteQuery();
}
This fails when the the file is deleted
Oct 02 2022 08:44 AM
See this link, I don't have any credit on the code