tags:

views:

95

answers:

2

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?

+1  A: 

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" />
Nat
Thanks Nate... but how do I include it in the Feature project. Is there some syntax for adding it to the feature.xml or manifest file? This is what I'm really trying to get at. Right now I'm manually copying the xml file to the server....
IrishChieftain
Cool Nat, that's what I needed to know :-)
IrishChieftain
+1  A: 

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 :)

ArjanP
The Web Part is basically a container for a set of security-trimmed links; the XML file contains attributes describing the type of security: custom role-based, Windows, or none... code reads the XML entries and determines the logged-in user's access rights before rendering each link.
IrishChieftain