Get the full absolute path to the project
String path = System.AppDomain.CurrentDomain.BaseDirectory.ToString ();
String path = Server.MapPath ("."); /This "." Can be replaced by other folder names in the project file
Output ASP. NET Web site path
private void responsehtml ()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
Sb. Append (String. Format ("Current time: {0}", Server.HTMLEncode (DateTime.Now.ToString ()));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Virtual path of the current request: {0}", Server.HTMLEncode (Request.currentexecutionfilepath)));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Get the root directory path of the current application: {0}", Server.HTMLEncode (Request.applicationpath)));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Virtual path of the current request: {0}", Server.HTMLEncode (Request.filepath)));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Virtual path of the current request: {0}", Server.HTMLEncode (Request.path)));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Get the physical file system path to the root of the currently executing application: {0}", Server.HTMLEncode (Request.physicalapplicationpath));
Sb. Append ("<br/>");
Sb. Append (String. Format ("Get the physical file system path corresponding to the requested URL: {0}", Server.HTMLEncode (Request.physicalapplicationpath));
Sb. Append ("<br/>");
Response.Write (sb.) ToString ());
}
Output: Current time: 2008-11-7 10:26:47
Virtual path of the current request:/test/gauge.aspx
Gets the root directory path of the current application:/test
Virtual path of the current request:/test/gauge.aspx
Virtual path of the current request:/test/gauge.aspx
Gets the physical file system path of the root directory of the currently executing application: D:\Asp.net test Project \test\
Gets the physical file system path that corresponds to the requested URL: D:\Asp.net test Project \test\