?
Solved

SP2010: Cannot delete folder in FeatureUninstalling method

Posted on 2012-09-21
1
Medium Priority
?
791 Views
Last Modified: 2012-10-03
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

0
Comment
Question by:tolppa
1 Comment
 
LVL 11

Accepted Solution

by:
svetaye earned 2000 total points
ID: 38421102
Hello,
Please try this :
web.Folders.Delete("Folder_URL");

The URL should be like this: "Style Library/myfolder"
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question