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

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 ")可取得路径不管你装在那个盘上。