if I understand you correctly, you can either using System.DirectoryServices; DirectoryEntry de =new DirectoryEntry("IIS://LOCALHOST/W3SVC/1/ROOT"); string s = (string)de.Properties["Path"].Value; Response.Write(s +"<BR>"); or s = System.Web.HttpContext.Current.Server.MapPath("/"); or simply s= Server.MapPath("/"); Response.Write(s +"<BR>");
IIS 的当前网站路径:Server.MapPath("/") 虚拟目录路径: Application("Path") = Server.MapPath(".") +"\"' or Request.ServerVariables("APPL_PHYSICAL_PATH")