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

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -