public void ExportToExcelByName(string fileNames)
{
//string filePath = "Z:\\BSS\\" + fileNames;
//string mapExcelFilesPath =
ConfigurationManager.RefreshSection("AppSettings");
string mapExcelFilesPath = ConfigurationManager.AppSettings["MapExcelFilesPath"];
string filePath = mapExcelFilesPath + fileNames;
//string filePath = mapExcelFilesPath + fileNames;
try
{
//string DownloadFileName = "~/uploads/" + e.CommandArgument.ToString();//文件路径
//string filepath = Server.MapPath(DownloadFileName);
string filename = Path.GetFileName(filePath);
FileInfo file = new FileInfo(filePath);
Response.Clear();
Response.ContentType = "application/octet-stream";
R
MVC Controller 下载指定路径的文件
最新推荐文章于 2023-08-09 17:03:30 发布
本文介绍了如何在ASP.NET MVC应用中创建一个Controller,以便用户可以从指定的服务器路径下载文件。通过设置HTTP响应头和利用FileResult类,可以实现安全且高效的文件下载流程。

最低0.47元/天 解锁文章
494

被折叠的 条评论
为什么被折叠?



