zoukankan      html  css  js  c++  java
  • C#实现下载功能

    protected void Button4_Click(object sender, EventArgs e)
            {
                string fileName = "aaa.txt";//客户端保存的文件名
                string filePath = Server.MapPath("DownLoad/aaa.txt");//路径
                //以字符流的形式下载文件
                FileStream fs = new FileStream(filePath, FileMode.Open);
                byte[] bytes = new byte[(int)fs.Length];
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();
                Response.ContentType = "application/octet-stream";
                //通知浏览器下载文件而不是打开
                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
  • 相关阅读:
    nginx用户统计
    mysql用户和授权
    memcache操作
    nginx memcache缓存
    memcached安装启动
    Unity 菜单拓展
    用C#创建XML, XML格式化输出
    解析swf文件头,获取flash的原始尺寸
    kinematic与static刚体不会触发任何接触回调
    git使用
  • 原文地址:https://www.cnblogs.com/guanjie20/p/2790440.html
Copyright © 2011-2022 走看看