Tag: delete listitems

SharePoint 2010 Delete items from List by using C#

If you want to delete all items in a list or empty / truncate the list by using c# you might be interested in this small script: SPList targetList = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, "/Lists/YourList")); SPList delList = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, "/Lists/YourList")); //If list is empty, do nothing, otherwise delete all items if (targetList.ItemCount > 0) { foreach(SPListItem delItem in…