How to: Add and Remove Mapped Folders

Some commonly used folders in SharePoint server, such as Images and Layouts, are deeply embedded in the file hierarchy. You can map these folders into a SharePoint project to access them more easily. Mapped folders are folders in the SharePoint project that correspond to the physical location of the files in the SharePoint Server installation.

When you deploy a SharePoint application, the contents of the mapped folder and all its subfolders are copied by the solution package (.wsp) onto the SharePoint server at the specified location in the SharePoint 2010 folder tree. This location is determined by the Deployment Location property that is set for the mapped folder. Any subfolders in the mapped folder are relative to the mapped folder's Deployment Location. Note that the name of the mapped folder does not determine where items are deployed, only the Deployment Location property does this.

You can add mapped folders to a project by using commands on the project's shortcut menu. Two commands add the most often-used mapped folders: IMAGES and LAYOUTS. Another shortcut menu command displays a folder selection dialog box that allows you to map any of the available SharePoint server folders.

Adding Mapped Folders to a Project

The following procedure describes how to add two mapped folders to a list definition project.

To add mapped folders to a project

  1. In Visual Studio, create a list definition project. On the File menu, point to New, and then click Project.

  2. In the New Project dialog box, expand either the Visual Basic or Visual C# folder, expand SharePoint, and then click 2010.

  3. In the project templates list, select List Definition and then click OK.

  4. Click the Finish button to accept the remaining default values.

  5. In Solution Explorer, right-click the project node (by default, ListDefinitionProject1), point to Add, and then click SharePoint "Images" Mapped Folder.

    Notice that a folder appears in your project named Images with a subfolder named ListDefinitionProject1. This is the mapped folder that will contain images for the list definition project.

  6. Again in Solution Explorer, right-click the project node, point to Add, and then click SharePoint Mapped Folder… to display the Add SharePoint Mapped Folder dialog box.

  7. In the tree view of folders available for mapping, click Resources, and then click OK.

    The Resources folder appears in your project. It can store items such as string resource files. Sub-folders can be useful for organizing the contents of a mapped folder, but they are not automatically created when you add a mapped folder by using the SharePoint Mapped Folder command. To add a sub-folder, right-click the Resources folder, point to Add, and then click New Folder.

Changing the Deployment Location of a Mapped Folder

By default, mapped folders are added relative to the SharePoint root installation (denoted by the token {SharePointRoot}). However, you can change this location by changing the Deployment location property of the mapped folder. Each mapped folder has its own Deployment location property.

To change the deployment location of a mapped folder

  1. In the project that you created earlier, click a mapped folder.

  2. In the Properties window, click the ellipsis (ASP.NET Mobile Designer ellipse) button on the Deployment location property to display the Add SharePoint Mapped Folder dialog box.

  3. In the Add SharePoint Mapped Folder dialog box, browse to the folder you want the mapped folder to point to.

  4. Click the node and then click OK to select it.

Renaming or Removing Mapped Folders

To rename or remove a mapped folder

  1. In a project that has one, right-click a mapped folder.

  2. To rename the mapped folder, in the shortcut menu, select Rename, enter the new name, and then press Enter.

    Alternatively, you can click the mapped folder that you want to rename and then type a new name in the Folder name property in the Properties window.

  3. To remove a mapped folder from the project, in the shortcut menu, select Delete and then click OK in the dialog box to confirm the removal.

See Also

Other Resources

Developing SharePoint Solutions