I have an ASP.NET application where in my APP_Code folder i have a class.In that i have the following code to read the content of an XML file which is in my root folder
XmlDocument xmlSiteConfig = new XmlDocument();
xmlSiteConfig.Load(System.Web.HttpContext.Current.Server.MapPath("../myConfig.xml"));
My Root folder is having several folders with nested inner folders for some.From the first level of folders when i call the piece of code in the Appcode class,I am able to load the XML file correctly since the path is correct.Now if i call the same piece of code from an innner folder,I am getting an error .If i change the code to the below it will work fine
xmlSiteConfig.Load(System.Web.HttpContext.Current.Server.MapPath("../../myConfig.xml"));
How can i solve this.I dont want to change the file path for various calls to this code.With what piece of code I can solve the issue so that the program will load the XML file irrespective of the calling position . Any advice ?
Thanks in advance