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();
             
            }
        }

  • 相关阅读:
    .net core相关博客
    通过几个Hello World感受.NET Core全新的开发体验
    ASP.NET Core 介绍
    ASP.NET MVC4企业级实战目录
    ASP.NET MVC4入门到精通系列目录汇总
    HTTP详解
    壮哉大微软,.Net人的春天来了,你准备好了嘛!
    简析 .NET Core 构成体系
    .Net Core[译文]
    OI再见
  • 原文地址:https://www.cnblogs.com/panshengqiang/p/2796642.html
Copyright © 2011-2022 走看看