Delete data from recycle bin which has same source/origion using C# sharepoint RRS feed

  • Question

  • Hi,

    I am looking for some custom c# code which would be useful to delete the items which are coming from same origin/source.

    Can anyone suggest how to filter out items from SharePoint recycle bin and delete them. 

    I know deleting all items is possible but let me know some reference for some specific items.



    Thursday, March 23, 2017 11:25 AM

All replies

  • Hi Sanjay,

    The following code snippet for your reference:

    using (SPSite site = new SPSite("http://sp13/sites/test1")) 
    	using (SPWeb web = site.OpenWeb()) 
    		var originalLocation = "sites/test1/Lists/CustomList12";
    		SPRecycleBinItemCollection rbItems =web.RecycleBin;
    		List<SPRecycleBinItem> listItems=new List<SPRecycleBinItem>();
    		foreach(SPRecycleBinItem rbItem in rbItems)
    			if (rbItem.DirName.Contains(originalLocation))
    		foreach(var item in listItems)

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Sunday, March 26, 2017 6:18 AM