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?
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"