0

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?

3

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="http://schemas.microsoft.com/sharepoint/">
    <Module Name="Xmlfile" Path="Xmlfile">
        <File Path="groups.xml" Url="Xmlfile/MyFile.xml" />
    </Module>
</Elements>

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

properties.Definition.RootDirectory + @"\Xmlfile\MyFile.xml"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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