At times, you may find that you wish to work with SharePoint recycle bins programmatically. I had a friend ask me this morning about approaches regarding dumping objects out of the recycle bin since he was experiencing storage issues disallowing deletion through the SharePoint web interface.
Working through the recycle bin through code is not a difficult task; there are a variety of object model pieces that you can use.
There are a few important ones:
SPRecycleBinItem - Represents an object in the Recycle Bin either at the site collection or site level
SPRecycleBinItemCollection - Represents a collection of SPRecycleBinItem objects
SPRecycleBinItemCollectionPosition - Represents the current page pointer of the recycle bin view
SPRecycleBinItemState - An enumeration containing the relevant SPRecycleBinItem object states, either FirstStageRecycleBin (site recycle bin) or SecondStageRecycleBin (site collection recycle bin)
SPRecycleBinItemType - An enumeration containing the SPRecycleBinItem object type, either:
Attachment
File
FileVersion
Folder
FolderWithLists
List
ListItem
SPRecycleBinOrderBy – Specifies the piece of order data when executing a query against against the recycle bin.
SPRecycleBinQuery – Specifies a query to run against the Recycle Bin in order to return SPRecycleBinItem objects
SPRecycleBinType – An enumeration containing the type of the Recycle Bin, either:
RecycleBin
SiteRecycleBin
So, how we can we use these to start working with the Recycle Bin? Fortunately, there are a variety of methods that the SharePoint API provides you in order to do so. For example, let’s assume that you wanted to dump all the SPRecycleBinItem objects for a site so that the Recycle Bin was then empty. We can build an SPRecycleBinItemCollection by creating a new SPWeb object which contains the RecycleBin collection, which allows a variety of method access. One of these methods includes the DeleteAll() method.
-
{
-
using (SPWeb web = site.OpenWeb())
-
{
-
try
-
{
-
web.RecycleBin.DeleteAll();
-
}
-
catch (Exception exception)
-
{
-
-
}
-
-
}
-
}











March 25th, 2008 at 6:08 pm
[...] Posted on March 26, 2008, 12:01 amby admin best video: 2007, foruser(); miami crane accidentworld of warcraft addons questUpward in 2007 - Chosun IlboAccording to the NSO, 345600 couples registered their marriages in 2007, the most since 1999. An NSO official said, "The Year of the Dog started on Jan.security functions do indeed provide some levewww.sharepointsecurity.comCPI Aero posts profitable 2007, compared to &3906 loss - NewsdayCPI president and chief executive Edward Fred said in a statementbefore markets opened that 2007 marked "a major turnaround" in the company&39s business. ...www.newsday.comMore innings for closers?I've been playing with my league settings in order to get closers theoretically the best RP on a given team more innings. What I'm seeing is that the AI tends to wait for save situations for closers and, as such, they're often throwing much fewer inningwww.ootpdevelopments.comFinancesWhat is the best way to fix finances from a 6.5 converted league? Here's the problem: Just about every team is in the red as far as money for FAs, etc. There are a ton of great FAs available, but they're just sitting in the FA pool because noone can siwww.ootpdevelopments.comIs there anybody alive out there?Season started today. A little news from the home front maybe?www.ootpdevelopments.com [...]