1

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.

1 Answer 1

1

Your code needs to activate the feature that provisions the files.

siteCollection.Features.Add([guid_of_your)feature])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.