Wednesday, December 19, 2012

SharePoint2010:Delete\Remove masterpages, css files, themes on feature deactivation

Scenario: How to delete Masterpages, css files and themes from the respective galleries on feature deactivation

Solution: Write following code on feature deactivation event
SPFile myTheme = System.Web.GetFile("_catalogs/theme/MyCustom.thmx");
if (myTheme.Exists)
{  
  myTheme.Delete("_catalogs/theme/MyCustom.thmx");
}