.CS
HttpContext.Current.Server.MapPath();//所在文件夾路徑
System.Web.HttpContext.Current.Request.PhysicalApplicationPat;//根路徑
.aspx
Server.MapPath(Request.ServerVariables["PATH_INFO"]) //頁面詳細路
Server.MapPath("/") //根目錄
Server.MapPath("") //當前代碼文件所在的目錄路徑
Server.MapPath(".")
Server.MapPath("../") //當前代碼所在路徑的上級路徑
Server.MapPath("..")
Page.Request.ApplicationPath
WinForm獲取 當前執行程序路徑的幾種方法
string str = System.Environment.CurrentDirectory;//獲取和設置當前目錄的完全限定路徑
string str = System.Windows.Forms.Application.StartupPath;//獲取啟動了應用程序的可執行文件的路徑,不包括可執行文件的名稱。
string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;//獲取新的 Process 組件並將其與當前活動的進程關聯的主模塊的完整路徑,包含文件名。
string str = System.AppDomain.CurrentDomain.BaseDirectory;//獲取當前 Thread 的當前應用程序域的基目錄,它由程序集沖突解決程序用來探測程序集。
string str = System.IO.Directory.GetCurrentDirectory();//獲取應用程序的當前工作目錄
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;//獲取和設置包含該應用程序的目錄的名稱。
string str = this.GetType().Assembly.Location;//獲取當前進程的完整路徑,包含文件名
string str = System.Windows.Forms.Application.ExecutablePath;//獲取啟動了應用程序的可執行文件的路徑,包括可執行文件的名稱。
