Server.MapPath在mvc中不起作用

0 c# asp.net-mvc asp.net-mvc-routing

我需要在文件夹路径中获取图像是否存在.我使用以下代码:

bool isExists = System.IO.Directory.Exists(Server.MapPath(FolderPath + "Logo.png"));
Run Code Online (Sandbox Code Playgroud)

但是如果文件存在,bool变量返回false.

Iro*_*eek 6

也许你应该使用File.Exists.

bool isExists = System.IO.File.Exists(Server.MapPath(FolderPath + "Logo.png"));
Run Code Online (Sandbox Code Playgroud)