string str = this.File1.PostedFile.FileName;
string ss = str.Substring(str .LastIndexOf ("\\")+1);
string s = Server.MapPath("..\\file\\" + ss);  这里提示用户代码未处理 invalidoperationexception 未能映射路径"/file/上传的文挡名"
path = "..\\file\\" + ss;
请各位达人帮帮忙啊!!!

解决方案 »

  1.   


    string str = this.File1.PostedFile.FileName; 
    string ss = str.Substring(str .LastIndexOf ("/")+1); 
    string s = Server.MapPath("../file/" + ss);  这里提示用户代码未处理 invalidoperationexception 未能映射路径"/file/上传的文挡名" 
    path = "../file/" + ss; 
      

  2.   

    Server.MapPath(" WebSitName/file\\" + ss);  
    //例  Server.MapPath("/web/App_Code/XXX.cs");  
      

  3.   

    Server.MapPath(" WebSitName /file\\" + ss);   
      

  4.   

    看看str在运行时的值就好处理了
      

  5.   

    Server.MapPath("../file/" + ss); 
      

  6.   

            string str = this.File1.PostedFile.FileName;
            string ss = str.Substring(str .LastIndexOf ("\\")+1);
            string s = Server.MapPath("WebSitName /file\\" + ss);
            path = "..\\file\\" + ss;
    改成这样还是不行的,错误提示“用户代码未处理Httpexception”未能映射路径啊?
    str是FILE1里的路径,SS是文件名,都有的,就是没有s
      

  7.   

    string str = this.File1.PostedFile.FileName; 
    string ss = str.Substring(str .LastIndexOf ("//")+1); 
    string s = Server.MapPath("..//file//" + ss);  这里提示用户代码未处理 invalidoperationexception 未能映射路径"/file/上传的文挡名" 
    path = "..//file//" + ss; 
      

  8.   

    你确定file目录和你的工程在一个文件夹下面么?
      

  9.   

    抱歉..
    如果你的file文件夹在站点根目录那么这样写就行了:
    Server.MapPath("file/" + ss); 
      

  10.   

    path = Server.MapPath("/file/" + ss);
    或者是
    path = Server.MapPath("~/file/" + ss);
      

  11.   

    是不是要和IIS的站点根目录一样啊?我的好象没有设置IIS啊,那怎么做啊?
      

  12.   

    楼主到MSDN上看看  Server.MapPath  吧我的URL:
    http://localhost:6668/NHWebPart/Default2.aspx
    NHWebPart 的根目录:
    E:\WorkSpace\DEMO\NHibernateStudy\NHWebPart
    访问跟目录下的App_Data:
    Server.MapPath( "App_Code" )
    映射的物理路径:E:\WorkSpace\DEMO\NHibernateStudy\NHWebPart\App_Code
    Server.MapPath( "App_Code/sss" )
    映射的物理路径:E:\WorkSpace\DEMO\NHibernateStudy\NHWebPart\App_Code\sss (App_Code下是空的)
    上面写的加 WebSitName 是不对的Server.MapPath("") 映射站点的跟目录,对应的物理路径就是E:\WorkSpace\DEMO\NHibernateStudy\NHWebPart\
    不知道搂主现在明白没有
      

  13.   

    明白了,呵呵,用 sbqcel 老大的解决了,也明白了,呵呵,谢谢各位老大了呵呵
      

  14.   

    string s = Server.MapPath("..\\file\\" + ss);  string newpath=("..\\file\\" + ss).replace("\\","/");
    string s = Server.MapPath(newpath);