• 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();
            }
  • 相关阅读:
    网络爬虫基础练习
    综合练习:词频统计
    画图
    Hadoop综合大作业
    hive基本操作与应用
    理解MapReduce计算构架
    熟悉HBase基本操作
    爬虫大作业
    熟悉常用的HDFS操作
    数据结构化与保存
  • 原文地址:https://www.cnblogs.com/guanjie20/p/2790440.html
Copyright © 2020-2023  润新知