I wrote the code in C # and printed the results on the terminal to confirm that it works. Currently, I am moving part of the code to the MVC 4 controller, and I have been able to consistently combine most of it, but I am having problems with one part.
I want to read the database file (database.dat), and later I want to write to the same file.
In my controller, I:
using (FileStream stream = File.OpenRead ("database.dat")) database = (List) formatter.Deserialize (stream);
and
using (Stream stream = File.Open ("database.dat", FileMode.Create)) formatter.Serialize (stream, database);
In both cases, the βFileβ in File.OpenRead and File.Open is underlined, and I get an error:
'System.Web.Mvc.Controller.File (byte [], string)' is a method that is not valid in this context ... "
Is there a way to achieve the same result in MVC?
source
share