标签:
public ActionResult ReviewFile(string folderName, string fileBasename, string extendName)
{
//以后根据后缀名返回相应的文件
var fileFullName = "~/" + folderName + "/" + fileBasename + extendName;
var path = Server.MapPath(fileFullName);
switch (extendName)
{
case ".html":
return File(path, "text/html");
break;
case ".txt":
return File(path, "text/plain");
break;
case ".doc":
return File(path, "application/msword");
break;
case ".xls":
var downLoadFileName = fileBasename + ".xls";
return File(path, "application/ms-excel", downLoadFileName);
//return File(path, "application/x-excel");
break;
case ".pff":
return File(path, "application/ms-powerpoint");
break;
case ".pdf":
return File(path, "application/pdf");
break;
case ".zip":
return File(path, "application/zip");
break;
default:
var noPointExtentName = extendName.Substring(extendName.IndexOf(‘.‘) + 1);
return File(path, "image/" + noPointExtentName);
}
}
标签:
原文地址:http://www.cnblogs.com/taoshengyujiu/p/5939291.html