Go back to index
How to deactivate a site collection feature
Following code block explains how to programmatically deactivate a site collection scoped feature. You can either give the name or Guid of the feature to be activated.
using System;
using SPTool.Library;
namespace SPTool.Test
{
class Program
{
static void Main(string[] args)
{
SPTSite site = new SPTSite("http://sptool");
// Deactivate site collection scoped feature
SPTReturn returnObj = site.DeactivateFeature("SPTool.Site.Config", false);
// Deactivate site collection scoped feature using Guid
//returnObj = site.DeactivateFeature("3FEF8D22-F191-41b6-8F1D-5D50D15BD2A6", false);
// Check the status of Deactivating the feature
if (returnObj.State == SPTState.Success)
{
// Deactivating Feature Successful
}
else
{
// Deactivating Feature Failed
}
}
}
}
Go back to index