Relative paths in an ASP.NET application code behind
Server.MapPath
- returns the path of the relative path; ~
ensures the relative path is related to the application root
xDoc.Load(Server.MapPath("~/Templates/template.cfg"));
I would probably use
xDoc.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "Template.cfg"));
This makes your XML loading code independent of ASP.NET. If you were to reuse it in, say, a Windows Forms application, this would give a path relative to the directory containing the Windows Forms exectuable.
xDoc.Load("~/Templates/template.cfg");
might work?