Delete SharePoint Lists Programmatically


 using (SPSite osite = new SPSite("SiteURL"))
            {
                using (SPWeb oweb = osite.OpenWeb())
                {
                    SPListCollection olistcoll = oweb.Lists;
                    Hashtable ht = new Hashtable();
                    foreach(SPList olist in olistcoll)
                    {
                        if (olist.Title.StartsWith("Test"))
                        {
                            ht.Add(olist.ID, olist.Title);                         
                        }
                    }
                    foreach (Guid ID in ht.Keys)
                        olistcoll.Delete(ID);
                }
            }

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell