1

i have used the below scripts to delete the folder in SharePoint 2013 enter image description here

This folder is generated by while creating my site which always creates the same folder name in the "Documents" Document Library of any site or sub-site. I’d like to simply delete it.

But i have another one requirement once site created default folder is available in the site,after running the script folder deleted. one new user joined later again he created new my site so folder available for him,so i want to delete the folder permanently at one time script running.

1
  • Are you in SharePoint Online? That script will not work in SPO...
    – wjervis
    Aug 22, 2014 at 10:35

2 Answers 2

2

For subsites, if you want to delete that folder after the web is provisioned, you can use the SPWebEventReceiver's WebProvisioned event. Here is an Example.

The event receiever as per the documentation, wont work when root web of the site collection is created. In this case, you can Staple a feature to the mysite so that when a mysite is created, the feature gets activate. On the feature activated event receiver, you can write the logic to delete the folder. Refer this link

2

You will have to create a feature which will get activated on creation of all my site and write code to delete the default folder programmatically. You will have to make use of feature stapling technique to achieve this.

Template Name for my site template is SPSMSITEHOST#0.

Follow this blog for feature stapling .

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.