zoukankan      html  css  js  c++  java
  • ASP.NET文件的下载

         /// <summary>
            /// 下载文件
            /// </summary>
            /// <param name="filePath">文件的路径</param>
            /// <param name="fileName">文件名(有时候文件名存在数据库中用于替换路径中的文件名)</param>
            public void FileDownLoad(string filePath, string fileName)
            {
                //判断文件是否存在
                if (System.IO.File.Exists(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    Response.Clear();
                    Response.AddHeader("Content-Disposition""attachment; filename=" + Server.UrlEncode(fileName));//解决中文文件名乱码   
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.Filter.Close();
                    Response.WriteFile(file.FullName);
                    Response.End();
                }
            }
  • 相关阅读:
    ul做导航栏
    论布局,bfc,margin塌陷和合并,经典bug
    mon-hom
    新浪下拉菜单模仿
    JQ筛选方法,筛选父子元素
    JQuery筛选选择器
    JQuery隐式迭代
    python 和 C# DES加密
    交互设计[1]--设计心理学
    javascript学习(9)——[设计模式]单例
  • 原文地址:https://www.cnblogs.com/malianyong/p/2866646.html
Copyright © 2011-2022 走看看