当前位置: 代码迷 >> ASP.NET >> FileUpload控件,上传的时分,只能上传到设定的绝对路径上么
  详细解决方案

FileUpload控件,上传的时分,只能上传到设定的绝对路径上么

热度:7096   发布时间:2013-02-25 00:00:00.0
FileUpload控件,上传的时候,只能上传到设定的绝对路径上么?
protected   void   ImageButton1_Click(object   sender,   ImageClickEventArgs   e)
        {
                string   savePath   =   @ "D:\YHLog\Product\ ";
                String   fileName   =   FileUpload1.FileName;
                fileName   =   fileName.Split( '. ')[1].ToString();
                savePath   +=   System.DateTime.Now.ToString( "yyyyMMddmmss ")   + ". "   +   fileName;
                this.FileUpload1.SaveAs(savePath);
}

savePath   只能写绝对路径么?但是我程序安装的时候不可能都放在D盘下的啊。

string   savePath   =   "~\YHLog\Product\ ";

我想达到以上效果,就是放在该CS文件所属文件夹里面,该这么写呢?
谢谢

------解决方案--------------------------------------------------------
string savePath = Server.MapPath( "YHLog\\Product ");
------解决方案--------------------------------------------------------
Server.MapPath( "YHLog\\Product ")可取得路径不管你装在那个盘上。
  相关解决方案