rendered paste bodyusing System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace InsulinSim
{
class SimFileManager
{
string err;
BinaryFormatter bformatter;
Stream stream;
public SimFileManager()
{
}
public Person openPerson(String path){
Person p;
stream = File.Open(path, FileMode.Create);
bformatter = new BinaryFormatter();
p = (Person)bformatter.Deserialize(stream);
stream.Close();
return p;
}
public bool savePerson(Person p, String path){
stream = File.Open(path, FileMode.Create);
bformatter = new BinaryFormatter();
try
{
bformatter.Serialize(stream, p);
}
catch
{
return false; ;
}
finally
{
stream.Close();
}
return true;
}
}
}