I'm trying to activate a sandbox solution on SharePoint 2013 using C#.
This is the code that I am using, it's working and the solution is activated however the files in the solution are not copied to the Style Library.
SPSite tempSite = new SPSite(Global.url);
SPUserToken ownertoken = tempSite.Owner.UserToken;
using (SPSite siteCollection = new SPSite(Global.url, ownertoken))
{
SPDocumentLibrary solutionGallery = (SPDocumentLibrary)siteCollection.GetCatalog(SPListTemplateType.SolutionCatalog);
SPFile file = solutionGallery.RootFolder.Files.Add(Global.sharepointSolutionName, File.ReadAllBytes(Global.currentDirectory));
SPUserSolution solution = siteCollection.Solutions.Add(file.Item.ID);
}
If I upload and activate the same solution manually everything works great.
Any idea of what I am missing here to get the files in the directories?
Thanks in advance.