Why can’t I use System.IO.File methods in an MVC controller?

You should prefix it with a namespace:

if (System.IO.File.Exists(picPath))
{ 
    //Other code
}

The reason for that is because you are writing this code inside a controller action which already defines a File method on the Controller class.

Leave a Comment