未能映射路径


今天要写一段读写文件的程序,使用System.Web.HttpContext.Current.Server.MapPath("/bin/WebSet.xml"),不料却出现“未能映射路径”的错误

,马上检查程序,感觉没有什么错误,于是乎网上搜,找啊找,就是找不到解决方案。只有自己慢慢调试了。 解决方案一:将绝对路

径/bin/WebSet.xml设为相对路径即可:~/bin/WebSet.xml 解决方案二:使用

System.Web.HttpContext.Current.Request.PhysicalApplicationPath+("/Bin/WebSet.xml"); 其中

System.Web.HttpContext.Current.Request.PhysicalApplicationPath表示的是项目的根目录。

posted @ 2010-06-18 13:19  赢风  阅读(506)  评论(0编辑  收藏  举报