首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

映射路径的有关问题

2012-02-20 
映射路径的问题?我的index.htm文件是放在网站的根目录的,可是我用stringfilenameHttpContext.Current.Ser

映射路径的问题?
我的index.htm文件是放在网站的根目录的,可是我用
string   filename   =   HttpContext.Current.Server.MapPath( "/index.htm ");
就会报错,说未能映射路径!

可是我用:
string   filename   =   HttpContext.Current.Server.MapPath( "~/index.htm ");
就是对的?

这个是怎么回事?我的index.htm文件明明放在网址根目录,这2个应该是等效的啊!

[解决办法]
string filename = HttpContext.Current.Server.MapPath( "/index.htm ");

改成

string filename = HttpContext.Current.Server.MapPath( "index.htm ");


热点排行