2

以前の投稿に関連する奇妙なエラーが発生しています。ダウンロードする前にファイルが存在するかどうかを確認しています。これは PDF では機能しますが、他の種類のドキュメントでは機能しません。

これが私のコントローラー アクションと、PDF および PowerPoint ファイルの一般的なパスです。PowerPoint は機能せず、File.Exists常にfalse. 両方のファイルが物理的に存在します。FileNotFoundExceptionこれは、非 PDFの結果になるため、非常に不可解です。

/Documents//FID//TestDoc//27a835a5-bf70-4599-8606-6af64b33945d/FIDClasses.pdf

~/ドキュメント//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");
}
4

1 に答える 1

0

PPT ファイルとディレクトリのアクセス許可を確認し、別の場所からダウンロードしたためにファイルに「ゾーン」情報が添付されていないことを確認します。

于 2010-05-20T17:07:07.737 に答える