日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

ASP.NET获取路径的方法

發(fā)布時間:2023/12/20 asp.net 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ASP.NET获取路径的方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

HttpContext.Current.Request.PhysicalPath;??? // 獲得當(dāng)前頁面的完整物理路徑.比如

F:\XFU.NSQS\project\website\Default.aspx
HttpContext.Current.Request.PhysicalApplicationPath;?// 獲得當(dāng)前程序運行的物理路徑比

如F:\XFU.NSQS\project\website\
HttpContext.Current.Server.MapPath(@"\"); 這個就是在頁面中的MapPath了.一樣用法

HttpRuntime.AppDomainAppPath //這個是新發(fā)現(xiàn)的,很好用.

還有一個是用來處理在asp.net中調(diào)用dll文件,而DLL文件如果想知道當(dāng)前的web站點的工作目錄可

以用
System.AppDomain.CurrentDomain.BaseDirectory

網(wǎng)站在服務(wù)器磁盤上的物理路徑: HttpRuntime.AppDomainAppPath
虛擬程序路徑: HttpRuntime.AppDomainAppVirtualPath

HttpContext.Current.Request.ApplicationPath虛擬應(yīng)用程序根路徑?
HttpContext.Current.Server.MapPath(".")當(dāng)前的絕對路徑?
HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath)系統(tǒng)的

根目錄

??????? sb.Append(string.Format("當(dāng)前請求的虛擬路徑: {0}",Server.HtmlEncode

(Request.CurrentExecutionFilePath)));
??????? sb.Append(string.Format("獲取當(dāng)前應(yīng)用程序的根目錄路徑: {0}",

Server.HtmlEncode(Request.ApplicationPath)));
??????? sb.Append(string.Format("當(dāng)前請求的虛擬路徑: {0}",Server.HtmlEncode

(Request.FilePath)));
??????? sb.Append(string.Format("當(dāng)前請求的虛擬路徑: {0}",Server.HtmlEncode

(Request.Path)));
??????? sb.Append(string.Format("獲取當(dāng)前正在執(zhí)行的應(yīng)用程序的根目錄的物理文件系統(tǒng)路徑:

{0}", Server.HtmlEncode(Request.PhysicalApplicationPath)));
??????? sb.Append(string.Format("獲取與請求的 URL 相對應(yīng)的物理文件系統(tǒng)路徑: {0}",

Server.HtmlEncode(Request.PhysicalApplicationPath)));

當(dāng)前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx
獲取當(dāng)前應(yīng)用程序的根目錄路徑: /aDirectory
當(dāng)前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx
當(dāng)前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx
獲取當(dāng)前正在執(zhí)行的應(yīng)用程序的根目錄的物理文件系統(tǒng)路徑: E:\Visual Studio 2005\
獲取與請求的 URL 相對應(yīng)的物理文件系統(tǒng)路徑: E:\Visual Studio 2005\\aDirectory\

?

???????????? sb.Append(string.Format("獲取項目完整的絕對路徑: {0}",

System.AppDomain.CurrentDomain.BaseDirectory.ToString()));
??????????? //僅在嘗試向此域中加載程序集之后,此屬性才可用
??????????? sb.Append(string.Format("獲取項目,它由程序集沖突解決程序用來探測動態(tài)創(chuàng)建的

程序集: {0}", System.AppDomain.CurrentDomain.DynamicDirectory));
??????????? sb.Append(string.Format("獲取磁盤上指向應(yīng)用程序目錄的物理路徑。: {0}",

System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath));
??????????? sb.Append(string.Format("獲取應(yīng)用程序的虛擬根路徑: {0}",

System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath));
??????????? sb.Append(string.Format("獲取站點的名稱。: {0}",

System.Web.Hosting.HostingEnvironment.SiteName));
??????????? //sb.Append(string.Format("獲取此應(yīng)用程序的虛擬路徑提供程序。: {0}",

System.Web.Hosting.HostingEnvironment.VirtualPathProvider));
??????????? sb.Append(string.Format("返回與 Web 服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件

路徑。: {0}", Server.MapPath("sss.aspx")));

?

轉(zhuǎn)載于:https://www.cnblogs.com/KingsLiu/p/9013067.html

總結(jié)

以上是生活随笔為你收集整理的ASP.NET获取路径的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。