downfile.aspx.cs
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:1k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.IO;
  12. using COM.OA.Entity;
  13. using COM.OA.BLL;
  14. public partial class gxxz_downfile : System.Web.UI.Page
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         //获取文件名称
  19.         int id = Int32.Parse(this.Request.QueryString["id"]);
  20.         files f = filesBLL.Select(id);
  21.         
  22.        
  23.         FileInfo info = new FileInfo(Server.MapPath(@"../gxxz/upload/"+f.f_filename));
  24.         Response.Clear();
  25.         Response.ClearContent();
  26.         Response.ClearHeaders();
  27.         string urlName = HttpUtility.UrlEncode(f.f_filename,System.Text.Encoding.UTF8);
  28.         Response.AddHeader("Content-Disposition", "attachment;filename=" + urlName);
  29.         Response.AddHeader("Content-Length", info.Length.ToString());
  30.         Response.AddHeader("Content-Transfer-Encoding", "binary");
  31.         Response.ContentType = "application/octet-stream";
  32.         Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
  33.         Response.WriteFile(info.FullName);
  34.         Response.Flush();
  35.         Response.End();
  36.   
  37.     }
  38. }