views:

15

answers:

1

my web application has an xml file here:

/files/xml/test.xml

I need to load a XDocument from within a class library project, how will I reference the xml? I don't want to pass any path parameters to this method.

I want to assume the location is fixed at /files/xml/test.xml.

How can I load a XDocument know this?

I don't seem to have access to server.mappath either.

+1  A: 

You should never assume locations. Your function really should take a file path, then from your Web Context, you call server.mappath to produce the correct path to load.

If you want to fix something, load it in as a resource constant or a const variable.

public static class Globals
{
   public const string TestPath = "/files/xml/text.xml";
}
Aren