I would like to add a Site template (WSP) to the solution gallery and activate it. TO this, I am using a feature which adds the file but it does not activate and it it looks like just a file that it does not recognise. What could be wrong with my code?
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
try
{
SPWeb web = properties.Feature.Parent as SPWeb;
SPWeb rootweb = web.Site.RootWeb;
SPDocumentLibrary solutionGallery = (SPDocumentLibrary)rootweb.Site.GetCatalog(SPListTemplateType.SolutionCatalog);
SPFile file = solutionGallery.RootFolder.Files.Add(@"Meeting Template.wsp", File.ReadAllBytes(@"Meeting Template.wsp"));
SPUserSolution solution = rootweb.Site.Solutions.Add(file.Item.ID);
rootweb.Features.Add(new Guid("850ECEC2-2D5E-4661-AC78-F133D782561C"), false, SPFeatureDefinitionScope.Site);
}
catch (Exception ex)
{
ILogger logger = new ULSLogger();
logger.LogError(ex.Message, ex);
}
}
This is my first time trying this out. I put the actual wsp in a Module called Solutions.
Please assist.