//提供下载的文件,不编码的话文件名会乱码   
        private string fileName = HttpContext.Current.Server.UrlEncode("规范.rar");   
        private string filePath = HttpContext.Current.Server.MapPath("规范.rar");   
        //使用TransmifFile下载文件   
        protected void btnDL1_Click(object sender, EventArgs e)   
        {   
            FileInfo info = new FileInfo(filePath);   
            long fileSize = info.Length;   
            Response.Clear();   
            Response.ContentType = "application/x-zip-compressed";   
            Response.AddHeader("Content-Disposition", "attachment;filename="+ fileName);   
            //不指明Content-Length用Flush的话不会显示下载进度   
            Response.AddHeader("Content-Length", fileSize.ToString());   
            Response.TransmitFile(filePath, 0, fileSize);   
            Response.Flush();   
            Response.Close();   
        }  

相关文章:

  • 2021-05-17
  • 2021-08-14
  • 2021-09-25
  • 2022-12-23
  • 2021-12-10
  • 2021-11-17
  • 2021-12-02
猜你喜欢
  • 2021-09-08
  • 2021-12-03
  • 2021-10-17
  • 2022-02-02
  • 2021-11-26
相关资源
相似解决方案