下载
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Common.ValueObject;
using BusinessLogic;
using System.IO;
public partial class Admin_Down : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TB_WenZhanFormVO formVo = new TB_WenZhanFormVO();
//取得更新ID
formVo.Id = Convert.ToInt32(Request["ID"].Trim()).ToString();
//取得数据并放入到FORMVO内
formVo = new TB_WenZhanBL().GetData(formVo);
// Response.Redirect("../Upload/" + formVo.GH_WenZhanFenLeiId + "/" + formVo.GH_FileName);
string strFilepath = Server.MapPath("~") + "Upload/" + formVo.GH_WenZhanFenLeiId + "/" + formVo.GH_FileName;
if (!File.Exists(strFilepath))
{
Response.Write("<center><font color='red' size='14pt'>你要下载的文件不存在。</font><br><a href='javascript:history.go(-1)'><b>返回</b></a></center>");
}
else
{
Response.ContentType = "application/x-zip-compressed";
string strFilename = formVo.GH_FileName;
if (strFilename.IndexOf(".") > 0)
{
strFilename = strFilename.Substring(strFilename.IndexOf("."));
strFilename = formVo.Id + strFilename;
}
Response.AddHeader("Content-Disposition", "attachment;filename=" + strFilename);
//string filename = Server.MapPath("DownLoad/CodeShark.zip");
Response.TransmitFile(strFilepath);
}
Response.Write(strFilepath);
}
}