SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using VS 2010 to create a SP 2010 web part. I want to include my images, css files and js files in the VS project, and have them be deployed to the correct location. My understanding is that I should be using SPWebPartManager.GetClassResourcePath() to get the urls for these items, and that the files should end up in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources\{web part name}\{version}__{pk token}.

  1. Is the above correct, or is there a better way?

  2. How to I include these fines in the VS project so that they are deployed to this location - e.g. is there a SharePoint mapped folder I have to put them in?

share|improve this question
up vote 2 down vote accepted

To deploy it to the wpresources location then you add the resources to the SPI (SharePoint item) in Visual Studio. For instance righ-click on a Web Part item and then add an existing item. Select the new item and look at its properties (F4) and check the Deployment Type. It should be set to NoDeployment by default. Change it to ClassResource...tada...done!

This will add the necessary XML elements (ClassResources/ClassResource) to your package

share|improve this answer
Awesome! It looks like I have to set this property per-file rather than per-folder (e.g. every image instead of the images folder). Is there quicker way? – bmm6o Apr 29 '10 at 20:34
You have to set it per file so that VS adds it automatically to the solution package. – Wictor Wilen MCA MCM MVP Apr 29 '10 at 20:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.