tags:

views:

34

answers:

1

Hi,

My library project is trying to open an XmlDocument from a file that's also contained in the library. How do I get the path of a file in the library so I can open it?

The current directory is not useful and Server.MapPath returns me the path of the main web application (MVC), so how do I get the path of the file in the library?

------- Edit The xml files are in a folder within the library project which wont exist when deployed. So it seems these files need to exist in a folder outside of the library (in a virtual directory in IIS for instance).

Steve

+1  A: 

If you're looking for the path of the currently-executing program or assembly (I'm not sure that you are), use the Location property of the Assembly you're interested in:

string path = Assembly.GetExecutingAssembly().Location;

or

string path = Assembly.GetAssembly(typeof(TypeInAssembly)).Location;
Michael Petrotta
Thanks for the answer. think Im having a stupid day and imagining a folder structure for my library once deployed!!! Thanks anyway
Steve Ward