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 System.IO;
using System.Data.SqlClient;
public partial class Downloadfile : System.Web.UI.Page
{
    public string oldName = "";
    public string filePath = string.Empty;
    public int uploadfileid = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cookEtwuser"];
        if (Request.Cookies["cookEtwuser"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        if (Request.QueryString["filename"] != null)
        {
            oldName = Request.QueryString["filename"].ToString();
            filePath = Server.MapPath("../etw_c_m/fujian/") + oldName;
            if (File.Exists(filePath) == false)
            {
                return;
            }
            DownFile(filePath, oldName);
        }
    }
    public void DownFile(string filename, string OldName)
    {
        System.IO.FileInfo file = new System.IO.FileInfo(filename);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=\" " + HttpUtility.UrlEncode(OldName, System.Text.Encoding.UTF8) + "\" ");
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(file.FullName);
        Response.End();
    }

}
