Monday, March 5, 2012

Delete all items from a Sharepoint list

private static void EmptyList(SPSite site, SPList list)
{
StringBuilder sbDelete = new StringBuilder();
sbDelete.Append("");
string command = "" + list.ID + "{0}Delete";
foreach (SPListItem item in list.Items)
{
sbDelete.Append(string.Format(command, item.ID.ToString()));
}
sbDelete.Append("
");
site.RootWeb.ProcessBatchData(sbDelete.ToString());
}

No comments:

Post a Comment