zoukankan      html  css  js  c++  java
  • web 文件下载

      private void FileDownload()
        {
            try
            {
                string FileName = "轉入地址错误信息.txt";
                // FileName = ".//路径//文件名.扩展名";
                string FullFileName = Server.MapPath(".") + "\\轉入地址错误信息.txt";

                //FileName--要下载的文件名
                FileInfo DownloadFile = new FileInfo(FullFileName);
                //if (DownloadFile.Exists)
                //{

                Response.Clear();
                Response.ClearHeaders();
                Response.Buffer = true;
                Response.ContentType = "application/octet-stream";
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
                // Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
                Response.WriteFile(DownloadFile.FullName);
                Response.Flush();
               

                //
            
                //}
                //else
                //{
                //    //文件不存在
                //}
            }
            catch (Exception ue)
            {
                //打开时异常了
            }
            finally
            {
                Response.End();
             
            }
        }

  • 相关阅读:
    十步完全理解 SQL
    Oracle VM Virtual
    Pycharm 使用
    Open Yale course:Listening to Music
    SQL 必知必会
    安装 SQL server 2008 R2
    Ubuntu安装mysql之后,编译找不到头文件
    core dump文件的生成
    Linux静态库与动态库制作过程
    GEC6818连接Ubuntu,下载程序至开发板
  • 原文地址:https://www.cnblogs.com/panshengqiang/p/2796642.html
Copyright © 2011-2022 走看看