controller.file is a method which is not valid in the given context code example
Example: controller.file is a method which is not valid in the given context
You probably have this method inside MVC controller in which File method exists. Add in your code System.IO.File instead of File