Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Friday, December 02, 2011

How to delete a List from SharePoint Programatically


This small code snippets will demonstrate how to delete a SPList from a sharepoint site.

To delete a list, you must specify the GUID of the list as the parameter for the Delete method. Use the ID property of the SPList class to find the GUID.

SPWeb mySite = SPContext.Current.Web;
SPListCollection lists = mySite.Lists;

SPList list = lists[ListName];
System.Guid listGuid = list.ID;

lists.Delete(listGuid);

No comments:

Post a Comment