本文实例讲述了ASP.NET编程获取网站根目录方法。分享给大家供大家参考,具体如下:
获取网站根目录的方法有几种如:
Server.MapPath(Request.ServerVariables["PATH_INFO"])
Server.MapPath("/")
Server.MapPath("")//当前代码文件所在的目录路劲
Server.MapPath(".")
Server.MapPath("../")
Server.MapPath("..")
Page.Request.ApplicationPath
以上的代码在http://localhost/EnglishClub/manage/WebForm1.aspx页面
运行结果:
C:\Inetpub\piled).Success) AppPath = AppPath.Substring(0, AppPath.Length - 1); } return AppPath;}
希望本文所述对大家asp.net程序设计有所帮助。