![](/img/trans.png)
[英]FileNotFoundException when loading assembly of ASP.NET Core MVC 5 project
[英]ASP.NET MVC FileNotFoundException error
我有一个与之前的帖子有关的奇怪错误。 下载前我正在检查文件是否存在。 这适用于PDF,但不适用于任何其他类型的文档。
这是我的控制器操作,以及PDF和PowerPoint文件的典型路径,PowerPoint不起作用, File.Exists
始终返回false
。 这两个文件实际上都存在。 这非常令人困惑,因为它会导致非PDF的FileNotFoundException
。
/Documents//FID//TestDoc//27a835a5-bf70-4599-8606-6af64b33945d/FIDClasses.pdf
〜/ Documents // FID // pptest // ce36e7a0-14de-41f3-8eb7-0d543c7146fe / PPttest.ppt
开玩笑的是,将文件路径复制并粘贴到资源管理器中会导致文件,那么可能是什么问题呢?
[UnitOfWork]
public ActionResult Download(int id)
{
Document doc = _documentRepository.GetById(id);
if (doc != null)
{
if (System.IO.File.Exists(Server.MapPath(doc.filepath)))
{
_downloadService.AddDownloadsForDocument(doc.document_id, _UserService.CurrentUser().user_id);
return File(doc.filepath, doc.mimetype, doc.title);
}
}
return RedirectToAction("Index");
}
检查PPT文件和目录的权限,检查文件没有附加“区域”信息,因为您是从其他地方下载的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.