Question

I need know old id of item in recycle bin or is there any way how to save its id in this item before deleting. When item is deleted, a new SPRecycleBinItem is created in Recycle Bin. And the only saved information about old item is DirName. But I need know more information.

[EDIT]

I have solved this issue. There is such property as LeafName in SPRecycleBinItem, which is the same as earlier Id in SPListItem for files (not for folders). If SPListItem was a file, then its LeafName would be "id" + "_.000" after deleting; If SPListItem was a folder, then its LeafName would be earlier Name of SPListItem.

Was it helpful?

Solution

I have solved this issue. There is such property as LeafName in SPRecycleBinItem, which is the same as earlier Id in SPListItem for files (not for folders). If SPListItem was a file, then its LeafName would be "id" + "_.000" after deleting; If SPListItem was a folder, then its LeafName would be earlier Name of SPListItem.

OTHER TIPS

SPRecycleBinItem.ID is not same as deletedItem.UniqueID. I have checked it. So you can't use them to identify deleted item in recycle bin. You can expiriment with DirName and LeafName, but there at least 3 different cases: item is folder, item is file, item is ordinary item.

The SPRecycleBinItem has the unique GUID which is the same before and after deletion. Therefore, you can retrieve it using the code below:

SPRecycleBinItemCollection itemColl = web.GetRecycleBinItems(q);
foreach (SPRecycleBinItem item in itemColl)
{
    Guid[] id = new Guid[1];
    id[0] = item.ID; //Gets the GUID of the item.

}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top