C#中下载项目中的文件

1.将需要下载的文档添加到项目的文件夹中

 

 2.接口部分

public IActionResult DownLoad()
        {
            var filePath = Directory.GetCurrentDirectory() + "\\UploadFileTemplate";
            var strFileName = "Manual courier dispatch record upload.xlsx";
            var strPath = filePath + @"\\" + strFileName;
            var stream = System.IO.File.OpenRead(strPath);
            return File(stream, "Application/x-msexcel", strFileName);
        }

3.前端部分

$("#Download").click(function () {
            window.location.href =' @Url.Action("DownLoad", "MR")';
        });

 

posted @   派大没有星  阅读(212)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示