Tuesday, November 25, 2014

Delete folder from Catalog masterpage

Introduction

We may came across this situation to delete a folder in catalog master page when you deactivating feature. Here we are going to see, how can we delete this kind of folder programmatically

Code

using (SPSite site = new SPSite(siteUrl))
{
 SPList listCatalog = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
                site.AllowUnsafeUpdates = true;
                SPFolder masterpageFolder = listCatalog.RootFolder.SubFolders["FolderName"];
                if (masterpageFolder != null)
                {
                    masterpageFolder.Delete();
                }
                site.AllowUnsafeUpdates = false;
                site.RootWeb.Update();
}

No comments:

Post a Comment