.NET将服务器文件导出

    导出文件:
                string filePath = Server.UrlDecode(filePath);
                if (File.Exists(filePath))
                {
                    FileInfo fi = new FileInfo(filePath);
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.Buffer = false;
                    Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Path.GetFileName(filePath), System.Text.Encoding.UTF8));
                    Response.AppendHeader("Content-Length", fi.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(filePath);
                    Response.Flush();
                    Response.End();
                }

原文地址:https://www.cnblogs.com/johnblogs/p/6709074.html