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("该文件已被删除");
        }

  

posted @ 2015-12-07 16:31  潇潇与偕  阅读(2113)  评论(0编辑  收藏  举报