Question

I've a WebApplication scoped feature which I need to install through code.

In short, I need to perform

stsadm -o installfeature -name MyFeature

through code. Any ideas?

Was it helpful?

Solution

Try this code:

public void InstallFeature(string name, bool force)
{
  string relativePath = name + @"\feature.xml";
  Microsoft.SharePoint.Administration.SPFarm.Local.FeatureDefinitions.Add(relativePath, Guid.Empty, force);
}

OTHER TIPS

Have a look at the code for the SharePoint Solution Installer on Codeplex.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top