C#下载文件

                string path = Server.MapPath("~/Upload/");
                string FileName = dt.Rows[0]["Files"].ToString();
                string filePath = path + FileName;
                if (File.Exists(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
                    Response.AddHeader("Content-length", file.Length.ToString());
                    Response.ContentType = "appliction/octet-stream";
                    Response.WriteFile(file.FullName);
                    Response.End();
                }

原文地址:https://www.cnblogs.com/huyueping/p/3361439.html