zoukankan      html  css  js  c++  java
  • 下載模板

      /// <summary>
            /// 下載文件的方法
            /// </summary>
            /// <param name="strSourceFile">文件的完整名稱</param>
            /// <param name="strFileName">下載文件保存的默認名稱</param>
            public static void ShowFile(string strSourceFile, string strFileName)
            {
                System.IO.FileInfo attachFile = new System.IO.FileInfo(strSourceFile);
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.ClearHeaders();
                HttpContext.Current.Response.Buffer = false;
                HttpContext.Current.Response.ContentType = "application/octet-stream";
                HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8));
                HttpContext.Current.Response.AppendHeader("Content-Length", attachFile.Length.ToString());
                HttpContext.Current.Response.WriteFile(strSourceFile);
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.End();
            }
    調用
       protected void LinkButton1_Click(object sender, EventArgs e)
            {
                string fileName = Server.MapPath("..\..\OPUPfiles\KS1OP.xls");
                string name = "KS1OP.xls";
                ShowFile(fileName, name);
            }
  • 相关阅读:
    保研练习题(5)
    保研练习题(4)
    保研练习题(3)
    保研练习题(2)
    保研练习题(1)
    基于邻接矩阵的拓扑排序--升级版
    基于邻接矩阵的拓扑排序
    vue 父组件调用子组件的函数
    vue 子组件调用父组件的函数
    JS 打乱数组顺序
  • 原文地址:https://www.cnblogs.com/xw2cc1314/p/4140300.html
Copyright © 2011-2022 走看看