日期:2014-05-18  浏览次数:20430 次

Server.mappath怎么用啊?
string   path   =   this.Server.MapPath( "./D: ");
                path.Clone();
这是website程序中的两小句,每次测试的时候都说 "“./D:”不是有效的虚拟路径。 ",是什么原因啊?

------解决方案--------------------
string path = this.Server.MapPath( "~/ ");
path就是网站所在的盘的目录了。比如网站放在D:/website/
此时取出的就是“D:/website/”

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
我的E-Mail:bdbox@163.com 请多指教!
------解决方案--------------------
./D:你这样写.是指当前目录,当前目录下哪有D盘啊?
当前目录就是当前页所在的目录
------解决方案--------------------
Server.MapPath( "/ "); //当前主目录的路径
Server.MapPath( "~/ "); //当前主目录的路径

Server.MapPath( "./ "); //当前文件所有目录的路径
Server.MapPath( " "); //当前文件所有目录的路径