Asp.net和winform程序下各種路徑輸出
一、Winform
EXE可執行程序文件物理路徑:E:\lrbin\AspNetLab\WinRunService\bin\Debug
1.获取程序的基目录System.AppDomain.CurrentDomain.BaseDirectory
E:\lrbin\AspNetLab\WinRunService\bin\Debug\
2.获取和设置当前目录(该进程从中启动的目录)的完全限定目录System.Environment.CurrentDirectory
E:\lrbin\AspNetLab\WinRunService\bin\Debug
3.获取应用程序的当前工作目录,注意工作目录是可以改变的,而不限定在程序所在目录System.IO.Directory.GetCurrentDirectory()
E:\lrbin\AspNetLab\WinRunService\bin\Debug
4.获取和设置包括该应用程序的目录的名称System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
E:\lrbin\AspNetLab\WinRunService\bin\Debug\
5.获取启动了应用程序的可执行文件的路径System.Windows.Forms.Application.StartupPath
E:\lrbin\AspNetLab\WinRunService\bin\Debug
6.获取启动了应用程序的可执行文件的路径及文件名System.Windows.Forms.Application.ExecutablePath
E:\lrbin\AspNetLab\WinRunService\bin\Debug\WinRunService.exe
7.获取模块的完整路径,包含文件名System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
E:\lrbin\AspNetLab\WinRunService\bin\Debug\WinRunService.exe
二、ASP.NET
URL:http://localhost:1280/TestMatch.aspx?username=sanshi&logincode=10001
物理路徑:E:\lrbin\AspNetLab\TEST\TestMatch.aspx
1.获取程序的基目录System.AppDomain.CurrentDomain.BaseDirectory
輸出:E:\lrbin\AspNetLab\TEST\
2.获取和设置包括该应用程序的目录的名称System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
輸出:E:\lrbin\AspNetLab\TEST\
3.獵取當前正在執行的服務器應用程序的根目錄的物理文件的系統路徑。Request.PhysicalApplicationPath
輸出:E:\lrbin\AspNetLab\TEST\
4.獲取與請求的URL相對應的物理文件系統路徑。Request.PhysicalPath
輸出:E:\lrbin\AspNetLab\TEST\TestMatch.aspx
5.获取模块的完整路径,包含文件名System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
輸出:c:\windows\system32\inetsrv\w3wp.exe
6.获取和设置当前目录(该进程从中启动的目录)的完全限定目录System.Environment.CurrentDirectory
輸出:c:\windows\system32\inetsrv
7.获取应用程序的当前工作目录,注意工作目录是可以改变的,而不限定在程序所在目录System.IO.Directory.GetCurrentDirectory()
輸出:c:\windows\system32\inetsrv
8.獲取當前請求有關的URL信息Request.Url.ToString()
輸出:http://localhost:1280/TestMatch.aspx?username=sanshi&logincode=10001
9.獲取絕對URI。Request.Url.AbsoluteUri
輸出:http://localhost:1280/TestMatch.aspx?username=sanshi&logincode=10001
10.獲取服務器的域名系統(DNS)主機名或IP地址和端口號。Request.Url.Authority
輸出:localhost:1280
11.獲得可安全用於DNS解析的未轉義主機名。Request.Url.DnsSafeHost
輸出:localhost
12.獲取此實例的主機部份。Request.Url.DnsSafeHost
輸出:localhost
13.獲取傳遞給System.Uri構造函數的原始URI字符串。Request.Url.OriginalString
輸出:http://localhost:1280/TestMatch.aspx?username=sanshi&logincode=10001
14.獲取遠程客戶端的IP主機地址。Request.UserHostAddress
輸出:127.0.0.1
15.獲取遠程客戶端的DNS名稱。Request.UserHostName
輸出:127.0.0.1
16.獲取當前請求的原始URL。Request.RawUrl
輸出:/TestMatch.aspx?username=sanshi&logincode=10001
17.獲取用問號分隔的System.Uri.AbsolutePath和System.Uri.Query。Request.Url.PathAndQuery
輸出:/TestMatch.aspx?username=sanshi&logincode=10001
18.獲取URI的絕對路徑Request.Url.AbsolutePath
輸出:/TestMatch.aspx
19.獲取文件名的本地操作系統表示形式Request.Url.LocalPath
輸出:/TestMatch.aspx
20.獲取當前請求的虛擬路徑。Request.Path
輸出:/TestMatch.aspx
21.獲取當前請求的虛擬路徑。Request.CurrentExecutionFilePath
輸出:/TestMatch.aspx
22.獵取當前請求的虛擬路徑。Request.FilePath
輸出:/TestMatch.aspx
23.獲取應用程序根的虛擬路徑,并通過對應程序根使用波形符(~)表示法(例如:以“~/page.aspx”的形式)使該路徑成為相對路徑 。Request.AppRelativeCurrentExecutionFilePath
輸出:~/TestMatch.aspx
24.獲取服務器上ASP.NET應用程序的虛擬應用程序根路徑。Request.ApplicationPath
輸出:/
25.獵取Request.CurrentExecutionFilePathExtension屬性中指定的文件名的擴展名。Request.CurrentExecutionFilePathExtension
輸出:.aspx
26.獲取 http 查詢字符串變量集合。Request.QueryString
輸出:username=sanshi&logincode=10001

浙公网安备 33010602011771号