//Web编程
- HttpContext.Current.Server.MapPath("FileName")
- System.Web.HttpContext.Current.Request.Path
TextBox1.Text = System.Web.HttpContext.Current.Server.MapPath("");
或是
TextBox1.Text = System.Web.HttpContext.Current.Server.MapPath("~");
ASP.NET 会将 ~ 运算符解析为当前应用程序的根目录。
返回结果不带/,如下
D:/我的文档/Visual Studio 2008/WebSites/WebSite1/scripts
-
//Windows编程
- System.Environment.CurrentDirectory