Question

I have some deleted files and folders in recycle bin. When I restore an item I need restore some other items according to my special algorithm. So, I use the following code snippet in Event Receiver to get items of recycle bin :

var recycleBinItems = properties.Web.GetRecycleBinItems(new SPRecycleBinQuery());

Then I enumerate on them. But it's a long operation, so I want to get a List of recycle bin to use CAML for retrieving data. How can I get an object of recycle bin ?

Was it helpful?

Solution

Unfortunately there is not an API call you can use to pass a CAML query to the recycle bin. As you have noted, there is a GetRecycleBinItems method on the SPWeb class, but according to the documentation on MSDN, it is only useful to control the sort order or limiting the returned items.

The RecycleBin property of the SPWeb is basically the same gateway, though it returns all the items by default.

On thing that may help you in the future is the knowledge that there are TWO recycle bins for an SPWeb - one at the web level and another at the site collection. You can configure the web level recycle bin to only hold on to files for a week or month - something that makes sense given your volume to limit the files you need to search through in the more general case. The files will move from the web level to the site collection level recycle bin, so you could still recover them if needed and they can be maintained there for a custom period of time as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top