Deleting many ListItems / SPFiles

Deleting a large amount of items in SharePoint can take some time. There are several ways on how to delete items:

  1. Deleting items using the OM with list.Items.DeleteItemById(itemID);
    • Deleting items using the SharePoint Webservices

      • Deleting items using the OM with web.ProcessBatchData(caml);
list.Items.DeleteItemById(itemID);

You should not use the Items property of a SPList multiple time. Instead create a variable, which stores list.Items and use it instead.

Deleting items using the SharePoint Webservices

You will use a Webservice, if you need to delete elements on a remote SharePoint Server

Deleting items using the OM with web.ProcessBatchData(caml);

The same caml you would use for the Webservice, can be used with web.ProcessBatchData(). Deleting a large amount of items is significantly faster, than deleting items one by one.

A big “Thank you” goes to Keith Bunge, Vincent Rothwell and steveC for their articles: