Programmatically emptying the web and site Recycle Bins
December 14, 2009 Leave a comment
I am currently working on a project, where I am migrating data from SQL into a SharePoint list. In doing so, I need to run this console utility through its paces, so, I have the need to constantly fill and purge the list several times.
Looping through each item within the list, for several thousand items is painstakingly slow however, so, I did find this great piece of code to do the job for me, which batch deletes all of the items from the specified list: http://code.msdn.microsoft.com/SharePointListDelete
Works exactly as advertised, and will now forever sit in my SharePoint tool belt. However, this method moves those items into the Recycle Bin. So, I thought I would share this with everyone else…
To empty both the web and site recycle bins, run the following code (modified for your environment of course…)