2014-01-09 41 views
0

我需要檢索圖像是否存在或不在文件夾路徑中。 我使用下面的代碼:Server.MapPath在mvc中不工作

bool isExists = System.IO.Directory.Exists(Server.MapPath(FolderPath + "Logo.png")); 

但是,如果該文件存在布爾變量返回false。

+3

什麼是'FolderPath'? –

+0

嘗試Path.Combine(folderPath,「Logo.png」) – kkocabiyik

+0

FolderPath是一個字符串,它是圖像的物理路徑。 – user3172321

回答

6

也許你應該使用File.Exists來代替。

bool isExists = System.IO.File.Exists(Server.MapPath(FolderPath + "Logo.png"));