相关疑难解决方法(0)

为什么我不能在MVC控制器中使用System.IO.File方法?

我试图在MVC控制器中使用它之前查看文件是否存在:

string path = "content/image.jpg";

if (File.Exists(path))
{ 
    //Other code
}
Run Code Online (Sandbox Code Playgroud)

File关键字以红色下划线,编译器显示错误:

System.Web.MVC.Controller.File(string, string, string) 是一种'方法',巫婆在给定的上下文中无效.

我如何File.Exists()在控制器中使用?

c# asp.net-mvc file

43
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

file ×1