Исключение при загрузке файла в MVC - PullRequest
0 голосов
/ 30 апреля 2018

Исключение выдает каждый раз, когда я загружаю файл. Вот исключение.

Server Error in '/' Application.
Could not find file 'F:\Caliber\CaliberCoaching\CaliberCoaching\App_Data\UploadData\New.docx'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not find file 'F:\Caliber\CaliberCoaching\CaliberCoaching\UploadData\New.docx'.

Это мой код загрузки

 public FileResult Download()
            {
                DirectoryInfo dirInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/UploadData/New.docx"));


                string contentType = string.Empty;
                string CurrentFileName = dirInfo.FullName ;

                if (CurrentFileName.Contains(".pdf"))
                {
                    contentType = "application/pdf";
                }

                else if (CurrentFileName.Contains(".docx"))
                {
                    contentType = "application/docx";
                }
                return File(CurrentFileName, contentType);  
            }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...