is there any method by which i will get server.mappath in a class file ??

Recommended Answers

All 2 Replies

myPath = HttpContext.Current.Server.MapPath("somePath"); and remember to add reference to System.Web

i am doing this
myPath = HttpContext.Current.Server.MapPath("somePath")
but not get the relative path
And then try for this - but also don't get the path

Actually i get the path of my XmlFile
I am doing like this
In Web.Config File
<add key="XmlFiles" value="/XmlFile/EmployeeManagement.xml"/>

And in Class File
internal string setting;
setting = ConfigurationManager.AppSettings["XmlFiles"];
var absoluteDataDirectory = Path.GetFullPath(setting);

but it take whole path of c drive by default and my project is in d drive..so not get the relative path

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.