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

上传文件,获取绝对路径失败,大家帮忙解决下。。
protected   void   btnInput_Click(object   sender,   EventArgs   e)
        {
                string   strFileName   =   this.File1.PostedFile.FileName;//获取上传文件的扩展名
                int   FileLength   =   strFileName.Length-strFileName.LastIndexOf( "\\ ")   -   1;//获取上传文件的长度
                strFileName   =   strFileName.Substring(strFileName.LastIndexOf( "\\ ")   +   1,   FileLength);
                string   strPath   =   Server.MapPath( "\\ ")   +   "Upload\\ ";
                //string   FileLength   =   this.File1.PostedFile.ContentLength.ToString();
                this.File1.PostedFile.SaveAs(strPath+strFileName);
        }
我使用的是VS.NET   2005
文件是放在
C:\Documents   and   Settings\Administrator\My   Documents\Visual   Studio   2005  
下面的。。。
我也在下面建立了Upload文件。。
但运行的时候都提示获取绝对路径失败。。。

------解决方案--------------------
哪句出错?
------解决方案--------------------
你这样试下
Server.MapPath( "~\\Upload\\ ");
其实你调试一下就ok了.

------解决方案--------------------
Server.MapPath( "~/ "+ "Upload\\ ");