c# - Relative paths in an ASP.NET application code behind -
being new asp.net i'm unsure of best solution problem. have line of code like:
xdoc.load("templates/template1.cfg");
xdoc xmldocument
. in project, @ top level there directory called templates. when run project in debug mode, directorynotfoundexception
, , apparently it's looking templates dir in c:\program files\common files\microsoft shared\devserver\10.0\templates
.
how can correctly point directory without hardcoding it?
server.mappath
- returns path of relative path; ~
ensures relative path related application root
xdoc.load(server.mappath("~/templates/template.cfg"));
Comments
Post a Comment