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 TopWinCMS.BLL;
namespace TopWinCMS.WebUI.Admin.Explorer
{
    public partial class DownloadFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = 0;
            Response.CacheControl = "no-cache";

            RightsCheck.CheckWorkPower("P_2");

            
            try
            {
                string thepath = Request["dir"];
                System.IO.FileInfo thefile = new System.IO.FileInfo(thepath);
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Length", thefile.Length.ToString());
                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(thefile.Name, System.Text.Encoding.UTF8));
                Response.WriteFile(thefile.FullName);
                Response.End();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
    }
}
