脚本宝典收集整理的这篇文章主要介绍了asp.net 文件路径之获得虚拟目录的网站的根目录,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
string Server.MapPath(string path)
返回与Web
服务器上的指定虚拟路径相对应的物理文件路径。
Server.MapPath(Request.Server
VARiables["PATH_INFO"])
Server.MapPath("/")
Server.MapPath("")
Server.MapPath(".")
Server.MapPath("
../")
Server.MapPath("..")
Page.Request.ApplicationPath
(HttpContext.
current.Request.Phys
icalApplicationPath);
以上的代码在http://localhost/EnglishCl
ub/manage/WebForm1.aspx页面
运行结果:
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\
由以上可以
知道:
要想获得要是建立的虚拟目录的网站的根目录可以这样使用:
Server.MapPath(Page.Request.ApplicationPath)
脚本宝典总结
以上是脚本宝典为你收集整理的asp.net 文件路径之获得虚拟目录的网站的根目录全部内容,希望文章能够帮你解决asp.net 文件路径之获得虚拟目录的网站的根目录所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。