C# to ASP.NET MVC FileStream Crossover -


this question has answer here:

i have written code in c# , printed results terminal confirm working. in process of transferring of code on mvc 4 controller , have been able successively merge of having issues 1 part.

i wish read database file (database.dat) , later on wish write same file.

in controller have:

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 'file' in file.openread , file.open underlined , receive error:

'system.web.mvc.controller.file(byte[], string)' 'method', not valid in given context ..."

is there way can achieve same result in mvc?

you'll have add fully-qualified name if want use file class in system.io (http://msdn.microsoft.com/en-us/library/system.io.file.aspx). should work:

using (filestream stream = system.io.file.openread("database.dat")){     database = (list)formatter.deserialize(stream); } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -