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 have an visual webpart and I need to populate drop down with content extracted from xml file. How can I provision that XML file with feature and then how can I access it from my codebehind to be able read it?

share|improve this question
up vote 3 down vote accepted

To deploy your file so that SharePoint can access it, you have several options but in your case as it is needed only by your feature event receiver you can deploy it under the feature's root folder. To do so, simply put your file inside a module with a deployment type of "ElementFile". Something like:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
    <Module Name="Xmlfile" Path="Xmlfile">
        <File Path="groups.xml" Url="Xmlfile/MyFile.xml" />

Then to access it in code behind read it from the path :

properties.Definition.RootDirectory + @"\Xmlfile\MyFile.xml"
share|improve this answer

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.