SPFolder / SPList: Deleting versus Recycling
The following code shows how to remove all documents from a folder:
int iCount = spFolder.Files.Count;
for (int i = 0; i < iCount; i++)
{
spFolder.Files[0].Delete();
}
Deleting documents with this code will delete permanently without using the recycle bin. To move the document to the recycle bin use the following code:
spFolder.Files[0].Recycle();
The SPItem class has a Recycle method as well as a Delete method and can be used in a similar way.
The first piece of code will only delete first file in the folder
Jackie boy
January 20, 2013 at 6:56 am
[…] SPFolder / SPList: Deleting versus Recycling | Nick Grattan’s Blog […]
Software development bookmarks | Ordo Rerum
March 16, 2017 at 4:33 pm