SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In an ItemDeleting event receiver, is there a way to find out whether SPListItem.Delete or SPListItem.Recycle was called?

I would like to write different things to my log here...

share|improve this question

I thought the answer was to check if the document was in the recycle bin:

private bool DocumentWasRecycled(SPItemEventProperties properties)
    Guid itemGuid = properties.ListItem.UniqueId;
    SPRecycleBinItem recycledItem = null;
        recycledItem = properties.Web.RecycleBin.GetItemById(itemGuid);
    catch { }
    return recycledItem != null;

But the problem is that if I do it in ItemAdding, it hasn't been put in the recycle bin yet, and if I do it in ItemAdded, I can no longer get the ID of the item...

share|improve this answer

This is a possible solution to my question

public override void ItemDeleted(SPItemEventProperties properties)
    string[] splittedBeforeUrl = properties.BeforeUrl.Split('/');
    string fileName = splittedBeforeUrl.Last();
    string filePath = properties.BeforeUrl.Replace(fileName, "").TrimEnd('/');
        foreach (SPRecycleBinItem item in properties.Web.RecycleBin)
            if (item.ItemType == SPRecycleBinItemType.File)
                if (fileName.Contains(item.Title) && item.DirName.Contains(filePath))
                    LogDeleteEvent(filePath, fileName);

But in my log, I also need some fields from the SPListItem, which is null in the ItemDeleted event. So I guess there is no solution...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.