If I have an ASP.NET code-behind, is there a way to compile the path of that file into the file somehow?
+1
A:
System.Reflection.Assembly.GetExecutingAssembly() has some good information.
jmaresca
2009-07-14 20:54:24
using reflection here is like using a rocket to kill a fly. There are much more efficient ways to get the path and append it.
see_sharp_guy
2009-07-14 21:12:45
A:
(I'm not sure what exactly you're trying to achieve but) you can get the path of the current page at any time, with code like the following (put it into the code-behind of your page):
// this prints the URL to the current page
Response.Write(Request.Url.ToString());
// this prints the server-path (where the page is stored on the server)
Response.Write(Server.MapPath(""));
M4N
2009-07-14 20:56:54
A:
~ refers to your project directory. so if your code behind file is called Default.aspx the path to it would be "~/Default.aspx".
to get the exact full path use "http current context map path". you can open a stream writer and add the path to the aspx file.
see_sharp_guy
2009-07-14 21:10:40