asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄
來源:懂視網(wǎng)
責(zé)編:小采
時間:2020-11-27 22:42:17
asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄
asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄:string Server.MapPath(string path) 返回與Web服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件路徑。 Server.MapPath(Request.ServerVariables[PATH_INFO]) Server.MapPath(/) Server.MapPath() Server
導(dǎo)讀asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄:string Server.MapPath(string path) 返回與Web服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件路徑。 Server.MapPath(Request.ServerVariables[PATH_INFO]) Server.MapPath(/) Server.MapPath() Server

string Server.MapPath(string path)
返回與Web服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件路徑。
Server.MapPath(Request.ServerVariables["PATH_INFO"])
Server.MapPath("/")
Server.MapPath("")
Server.MapPath(".")
Server.MapPath("../")
Server.MapPath("..")
Page.Request.ApplicationPath
(HttpContext.Current.Request.PhysicalApplicationPath);
以上的代碼在http://localhost/EnglishClub/manage/WebForm1.aspx頁面
運行結(jié)果:
C:\Inetpub\wwwroot\EnglishClub\manage\WebForm1.aspx
C:\Inetpub\wwwroot\
C:\Inetpub\wwwroot\EnglishClub\manage
C:\Inetpub\wwwroot\EnglishClub\manage
C:\Inetpub\wwwroot\EnglishClub\
C:\Inetpub\wwwroot\EnglishClub
C:\Inetpub\wwwroot\EnglishClub\
由以上可以知道:
要想獲得要是建立的虛擬目錄的網(wǎng)站的根目錄可以這樣使用:
Server.MapPath(Page.Request.ApplicationPath)
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄
asp.net 文件路徑之獲得虛擬目錄的網(wǎng)站的根目錄:string Server.MapPath(string path) 返回與Web服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件路徑。 Server.MapPath(Request.ServerVariables[PATH_INFO]) Server.MapPath(/) Server.MapPath() Server