zoukankan      html  css  js  c++  java
  • ASP.NET提供下载

    //提供下载的文件,不编码的话文件名会乱码   
            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();   
            }  

  • 相关阅读:
    无题
    赌对了
    赌:
    这次是真的再见了,oi退役回忆录
    线段树(lazy标记)
    《挑战》2.1 POJ POJ 1979 Red and Black (简单的DFS)
    《挑战》2.1 POJ 2386 Lake Counting (简单的dfs)
    TC安装全系列教程
    ProblemC 剪花布条(KMP基础)
    多校+CF简单题
  • 原文地址:https://www.cnblogs.com/yxlblogs/p/3043525.html
Copyright © 2011-2022 走看看