zoukankan      html  css  js  c++  java
  • asp.net文件下载

    protected void Button1_Click(object sender, EventArgs e)
        {
            this.DownLoadFile("说明.txt");
        }

        //下载函数
        private void DownLoadFile(string fileName)
        {  
            string filePath = Server.MapPath(".") + "\\" + fileName;
            if (File.Exists(filePath))
            {
                FileInfo file = new FileInfo(filePath);
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
                Response.AddHeader("Content-Disposition""attachment; filename=" + Server.UrlEncode(file.Name)); //解决中文文件名乱码    
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "appliction/octet-stream";
                Response.WriteFile(file.FullName);
                Response.End();
            }
        }
  • 相关阅读:
    bootstrap常用快捷查找
    jquery
    javascript
    移动端心得总结
    css。过渡动画
    css。。段落样式
    css。元素样式、边框样式
    css3
    css
    Hbuilder 的快捷方式
  • 原文地址:https://www.cnblogs.com/shiningrise/p/2635957.html
Copyright © 2011-2022 走看看