当前位置:编程学习 > C#/ASP.NET >>

.Net 下载文件,用的MVC模式

代码如下, 

public ActionResult Download(string fName,string fPath)
        {
            string fileName = fName; 
            string filePath = fPath; 

            FileStream fs = new FileStream(filePath, FileMode.Open);
            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            Response.Charset = "UTF-8";
            //Response.ContentEncoding = System.Text.Encoding.GetEncoding("");
            Response.ContentType = "application/octet-stream";

            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
            return new EmptyResult();
        }
测了一下,下载文件最大只能是100多M的,如何实现无限制大小的文件下载! --------------------编程问答-------------------- 点他
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,