下载

protected void dFile(string name)
        {
            string path = Server.MapPath("~") + name;
            //初始化 FileInfo 类的实例,它作为文件路径的包装
            FileInfo fi = new FileInfo(path);
            
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
            //Response.AddHeader("Content-Length", fi.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.Filter.Close();
            Response.WriteFile(fi.FullName);
            Response.End();
        }      

原文地址:https://www.cnblogs.com/codeloves/p/2995190.html