Creating Folders using Modules

Sometimes, you will find yourself in a situation that you not only provision pages to SharePoint content database, but also you need to create folder in which those pages will be provisioned.

Consider the following example :

 <File Url="MyPagesFolder/MyPage.aspx" />

This way, you can use the URL attribute of the file element to create folders in your site. SharePoint will create the folder “MyPagesFolder”  if it doesn’t exist. You can do this trick either within the URL attribute of the Module element or the file element.

Another point to consider in the previous example is that I omitted the Path attribute which makes the URL attribute acts as both (URL and path), so now SharePoint will get files from MyPagesFolder relative to the feature folder, then it will create a folder called MyPagesFolder and provision MyPage.aspx to it.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s