ASP. NET project path get method "Go"

Source: Internet
Author: User

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\

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.