Link to home
Start Free TrialLog in
Avatar of tolppa
tolppa

asked on

SP2010: Cannot delete folder in FeatureUninstalling method

Hello. I would like to remove folder when my webpart is uninstalled. Unfortunately this code does not work -> object is null exeption. What am I doing wrong? Code (spcontext.current.web) do work when used in FeatureDeactivating method (user deactivates feature manually).

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                    SPSite siteCollection = properties.Feature.Parent as SPSite;

                    if (siteCollection != null) 
                    {
                        SPWeb web = siteCollection.RootWeb;
                        web.Folders["Style Library"].SubFolders["myfolder"].Delete();
                    }
               });

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of svetaye
svetaye
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial