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();
}
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.