Thursday, February 05, 2009

Delete all Items in SharePoint List

You might end up with this requirement quite often and and try top down approach for delete :
for (int count=0;count < itemCount ; count++)
{ itemcoll[count].Delete(); }

and bump into exceptions , well the other way to do it is bottom up delete

for (int count =itemCount-1 ; count>0 ; count--)
{ itemcoll[count].Delete(); }

2 comments:

Anonymous said...

Try this too,

Delete item from SharePoint List and more

Manesh Golekar said...

Updated Code - Removes All Items

int itemCount = list.ItemCount;
SPListItemCollection itemcoll = list.Items;
//iterate & delete items
for (int count = itemCount - 1; count >= 0; count--)
{
itemcoll[count].Delete();
}
list.Update();

Handle the error “OwnershipControlsNotFoundError” for buckets created prior to April 2023 when the bucket ownership was defaulted to “Object Writer”

Here you go published a  python code sample written for migrating S3 bucket ownership controls between AWS accounts. The code is written to ...