代码
1 protected void Page_Load(object sender, EventArgs e)
2 {
3 StringBuilder sb = new StringBuilder();
4 String pathstring = Context.Request.FilePath.ToString();
5 sb.Append("Current file path = " + pathstring + "<br>");
6 sb.Append("File name = " + VirtualPathUtility.GetFileName(pathstring).ToString() + "<br>");
7 sb.Append("File extension = " + VirtualPathUtility.GetExtension(pathstring).ToString() + "<br>");
8 sb.Append("Directory = " + VirtualPathUtility.GetDirectory(pathstring).ToString() + "<br>");
9 Response.Write(sb.ToString());
10
11 StringBuilder sb2 = new StringBuilder();
12 String pathstring1 = Context.Request.CurrentExecutionFilePath.ToString();
13 sb2.Append("Current Executing File Path = " + pathstring1.ToString() + "<br>");
14 sb2.Append("Is Absolute = " + VirtualPathUtility.IsAbsolute(pathstring1).ToString() + "<br>");
15 sb2.Append("Is AppRelative = " + VirtualPathUtility.IsAppRelative(pathstring1).ToString() + "<br>");
16 sb2.Append("Make AppRelative = " + VirtualPathUtility.ToAppRelative(pathstring1).ToString() + "<br>");
17 Response.Write(sb2.ToString());
18 }
2 {
3 StringBuilder sb = new StringBuilder();
4 String pathstring = Context.Request.FilePath.ToString();
5 sb.Append("Current file path = " + pathstring + "<br>");
6 sb.Append("File name = " + VirtualPathUtility.GetFileName(pathstring).ToString() + "<br>");
7 sb.Append("File extension = " + VirtualPathUtility.GetExtension(pathstring).ToString() + "<br>");
8 sb.Append("Directory = " + VirtualPathUtility.GetDirectory(pathstring).ToString() + "<br>");
9 Response.Write(sb.ToString());
10
11 StringBuilder sb2 = new StringBuilder();
12 String pathstring1 = Context.Request.CurrentExecutionFilePath.ToString();
13 sb2.Append("Current Executing File Path = " + pathstring1.ToString() + "<br>");
14 sb2.Append("Is Absolute = " + VirtualPathUtility.IsAbsolute(pathstring1).ToString() + "<br>");
15 sb2.Append("Is AppRelative = " + VirtualPathUtility.IsAppRelative(pathstring1).ToString() + "<br>");
16 sb2.Append("Make AppRelative = " + VirtualPathUtility.ToAppRelative(pathstring1).ToString() + "<br>");
17 Response.Write(sb2.ToString());
18 }