1
votes

Currently I have a custom Web Part, deployed as a Feature, and it accesses an XML file as follows:

string sUri = @"C:\inetpub\wwwroot\wss\VirtualDirectories\80" + @"\wpresources\links.xml";

ds = new DataSet(); ds.ReadXml(sUri);

What is the correct way to include an XML file as part of a SharePoint Feature deployment?

2

2 Answers

1
votes

Load it into the 12 hive under your layouts directory and link to it via

http://[currentsite]/[currentweb]/_layouts/links.xml

. Or add a subdirectory to group all of your file together. e.g.

http://[currentsite]/[currentweb]/[myFeature]/_layouts/links.xml

how do I include it in the Feature project...?

I am using STSDEV and that automagically puts an entry into the manifest.xml under

<Templates> 

e.g.

<TemplateFile Location="LAYOUTS\[myFeature]\links.xml" /> 
1
votes

In my mind there are a few correct ways. The place you want to deploy your xml file I would not pick however.

It would have to be either:

  1. deployed directly in the 12-hive using a solution file (like Nat suggests, I'd use WSPBuilder though)
  2. deployed to the site using a feature ( see: http://msdn.microsoft.com/en-us/library/ms441170.aspx ) this would make the file be pushed into the content database for your code to read.

To my knowledge there is no simple way of deploying files to the InetPub folder for your website. I needed this once to deploy a .browser file and ended up creating a feature receiver that copied the file from the 12-hive into the InetPub folder.

Maybe if you explain what the xml file is for, the answers can be better :)