Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

How to delete SPRecycleBin items?

   1: SPSite spSite = new SPSite("http://nishand:100/sites/InternetSite/");
   2: SPRecycleBinItemCollection collection = spSite.RecycleBin; 
   3:  
   4: for (int x = 0; x < collection.Count ; x++) 
   5: {           
   6:               collection[x].Delete(); x = x-1;                               
   7: }
   8:  

The above code works only for the items deleted by the user who runs the application/current user.
Any attempt to delete a file deleted by other user from the recycle bin file will result in an exception "Operation is not valid due to the current state of the object."

We do have an overridden Delete() function, that helps to delete all RecycleBin items.

SPRecycleBinItemCollection.Delete(Guid [] guids)

Hope this works for you!

Published Saturday, June 07, 2008 4:44 PM by nishandv

Comments

 

Blog Technique de Romelard Fabrice said:

Un besoin très classique pour tout responsable de ferme SharePoint 2007 est la gestion des corbeilles.

June 8, 2008 6:16 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker