使用FileResult下载ASP.NETMVC中任何类型的文件?
public ActionResult Download(string filePath, string fileName){ string fullName = Path.Combine(GetBaseDir(), filePath, fileName); byte[] fileBytes = GetFile(fullName); return File( fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);}byte[] GetFile(string s){ System.IO.FileStream fs = System.IO.File.OpenRead(s); byte[] data = new byte[fs.Length]; int br = fs.Read(data, 0, data.Length); if (br != fs.Length) throw new System.IO.IOException(s); return data;}
大话西游666
相关分类