请问在类库中怎么取得网站的根目录的物理地址? 我想写一个类库,里面需要取得一个相对于根目录的xml文件里的一些设置参数,请问在类库李怎么取得网站根的物理路径?谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string XmlFile = HttpContext.Current.Server.MapPath("~/Message.xml"); System.Web.HttpContext.Current.Request System.Web.HttpContext.Current.Request.PhysicalApplicationPath System.Web.HttpContext.Current.Server.MapPath("~/"); string appRoot = System.Web.HttpContext.Current.Server.MapPath("~/"); string url = HttpContext.Current.Server.MapPath("fileUrl"); 1、HttpContext.Current.Server.MapPath("~/Message.xml");上面的被限制之后我会用下面的:2、System.Web.HttpContext.Current.Request.PhysicalApplicationPath+"文件夹\文件名"下面的HttpContext.Current.Server.MapPath("~")== System.Web.HttpContext.Current.Request.PhysicalApplicationPath HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath+"//Message.xml"); System.Web.HttpContext.Current.Request.PhysicalApplicationPath HttpContext.Current.Server.MapPath("~"); Server.MapPath我就知道进来回答的一堆,我纯接分 System.Web.HttpContext.Current.Request.PhysicalApplicationPath这个比Server.mapth好很多 。后者是根据你具体在哪个文件夹里面引用,得到目录根文件夹的物理路径,而不是真实的网站根目录 我觉得在类库中不要用System.Web.HttpContext.Current.Request比较好,还是把路径作为参数传进去,这样 web 和win 可以一起共用这个类库。 HttpContext.Current.Server.MapPath(strPath); asp.net图片上传sql数据库 谁能给我一个播放视频的插件代码啊?ASP.NET 请问,有关树型结构的权限表 sql 语句 if 问题 Visual Studio .NET 已检测到指定的 Web 服务器运行的不是 ASP.NET 1.1 版 公司要用.net做网站!能不能dreamweaver先做好界面? 如何 点击 IE的后退按扭 会出现如正文里面的信息。 DateGrid排序问题? GridView的 RowCommand事件后绑定问题 哪里可以得到免费的SSL证书? 文件所在的位置? 关于virtual和override的问题
上面的被限制之后我会用下面的:
2、System.Web.HttpContext.Current.Request.PhysicalApplicationPath+"文件夹\文件名"
下面的
HttpContext.Current.Server.MapPath("~")== System.Web.HttpContext.Current.Request.PhysicalApplicationPath
我就知道进来回答的一堆,我纯接分
这个比Server.mapth好很多 。后者是根据你具体在哪个文件夹里面引用,得到目录根文件夹的物理路径,而不是真实的网站根目录