首页 > 技术文章 > IIS站点下多应用程序 C#获取根目录方法

ding2011 2018-03-13 10:02 原文

获取站点根目录:

Server.MapPath(Request.ServerVariables["PATH_INFO"])
Server.MapPath("/")
Server.MapPath("")//当前代码文件所在的目录路径
Server.MapPath(".")
Server.MapPath("../")
Server.MapPath("..")

  

获取应用程序根目录:

// 获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory

// 获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

  

推荐阅读