关于"未能映射路径"问题
来源:互联网 发布:手机淘宝网app下载 编辑:程序博客网 时间:2024/04/30 11:03
未能映射路径,在作页面生成时,老是出现"未能映射路径"/aa/bb/cc".
研究了半天,终于找出原因了,Server.Mapth(string path),path-->是相对路径。所以,改为Server.Mapth("aa/bb/cc")就好了,.net 会自动找"aa/bb/cc",返回相对路径。
//如果不存在,使用System.IO.Directory.CreateDirectory创建文件夹。
if (!System.IO.Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) { System.IO.Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(path)); } System.IO.StreamWriter sw = new System.IO.StreamWriter(System.Web.HttpContext.Current.Server.MapPath(path + "/" + file), false, System.Text.Encoding.GetEncoding("gb2312")); sw.Write(temp);
切记: Server.Mapth("相对路径").
解决方案一:将绝对路径/bin/WebSet.xml设为相对路径即可:~/aa/bb/WebSet.xml
解决方案二:使用System.Web.HttpContext.Current.Request.PhysicalApplicationPath+("/Bin/WebSet.xml");
其中System.Web.HttpContext.Current.Request.PhysicalApplicationPath表示的是项目的根目录。
解决方案三:将/aa/bb/cc改为aa/bb/cc 。
- 关于"未能映射路径"问题
- 关于"未能映射路径"问题
- 关于"未能映射路径"问题
- 未能映射路径“/App_GlobalResources/” 问题修复
- VS2005未能映射路径
- VS2005未能映射路径
- 未能映射“”路径
- win7 未能映射路径
- WebConfigurationManager.OpenWebConfiguration("~")未能映射路径
- 未能映射路径 的解决办法
- webapi 关于设置路径的问题,映射
- 服务器上发布网站时,提示“未能映射到路径”
- 黑马学习笔记——“未能映射路径”解决方法
- SpringMVC资源路径映射问题
- win7下vs2005调试asp网页时出现“加载配置文件时出错: 未能映射路径'/' "错误
- vs2008调试c#网页时出现“加载配置文件时出错: 未能映射路径'/' "错误 .
- asp.net FreeTextBox 使用 和 未能映射路径“/aspnet_client/FreeTextBox/Languages/en-US.xml”
- 关于 IIS 关于未能创建 Mutex 问题的解决
- 0×00000xxx型内存错误
- 小心使用zeromq
- frameworksssss
- 正则表达式
- kdesvn中删除文件夹后commit出现Aborting commit: 'pdu/rootfs/busybox-1.15.3' remains in tree-conflict错误
- 关于"未能映射路径"问题
- Qt: 给Widget设置背景图片
- 如何用servlet/jsp实现在线用户统计
- Sort Table
- 不错的电子书籍下载网址
- NDK Makefile文件中LOCAL_LDLIBS和LOCAL_CFLAGS介绍
- Linux时间函数之gettimeofday()函数之使用方法
- js 打印页面局部内容
- linux下错误的捕获:errno和strerror的使用