下载文件

来源:互联网 发布:百度seo推广软件 编辑:程序博客网 时间:2024/06/15 07:38
public void DownLoad()        {            string path = Server.MapPath("~/TempFile/客户.xlsx");            FileInfo fi = new FileInfo(path);            if (fi.Exists)            {                Response.Clear();                Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("客户.xlsx"));                Response.AddHeader("Content-Length", fi.Length.ToString());                Response.ContentType = "application/octet-stream;charset=gb2321";                Response.WriteFile(fi.FullName);                Response.Flush();                Response.Close();            }        }