Active/Deactive feature for sharepoint

原文链接:http://www.sharepointdiary.com/2012/07/activate-deactivate-features-programmatically.html

 SPSite oSPSite = new SPSite(SiteURL);
 
            //Get the Feature to Activate
            SPFarm farm = oSPSite.WebApplication.Farm;
            SPFeatureDefinitionCollection features = farm.FeatureDefinitions;
            SPFeatureDefinition feature = features[new Guid("05BA4E54-C1E9-4244-8276-06451EBBB260")];
 
 
            if (feature != null)    //Make sure Feature is installed!
            {
                // Activate the feature
                oSPSite.Features.Add(feature.Id, true);
                //call oSPSite.Features.Remove
            }


Read more: http://www.sharepointdiary.com/2012/07/activate-deactivate-features-programmatically.html#ixzz2dQV6NDYU

原文地址:https://www.cnblogs.com/PeterHome/p/3291260.html