Possible Duplicate:
HttpContext.Current.Server null
I have three projects in my ASP .NET solution:
- a class library
- a web application
- a windows service
I have a folder in my web application with an XML file. An XMLreader from class library function needs to be populated with this XML file. I have added this:
var reader = XmlReader.Create(HttpContext.Current.Server.MapPath("~/TestDevice/Data.xml"), settings);
When this function is called from we application, It works. When this function of class library is called from windows application, I get null reference at HttpContext.Current.Server because it is not available in windows application. I don't want to give hardcode path although that works for both windows and web application. Can I use some don't function to access files from different projects or any alternate of server.mappath. Please suggest solution
Thanks