C# Mvc中文件下载

        public ActionResult DownloadFile(string id)
        {
            var fileinfo = CommonAnnexService.Get(id);
            if (fileinfo.StatusValue == (long)PublicStatusEnum.正常)
            {
                if (System.IO.File.Exists(Server.MapPath(fileinfo.SavePath)))
                {
                    return File(Server.MapPath(fileinfo.SavePath), "application/octet-stream", fileinfo.AnnexName +"."+ fileinfo.AnnexType);
                }
                return Fail("该文件已丢失");
            }
            return Fail("该文件已被删除");
        }

  

你可能感兴趣的:(C# Mvc中文件下载)