public static HabitList Initialize() { if (_habits == null) { _habits = new HabitList(); Save.Load(ref _habits, _path); } return(_habits); }
public static void SaveLoad(HabitList fData, string path) { try { using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, fData); } } catch { } }
public static void Load(ref HabitList fData, string path) { if (!File.Exists(path)) { return; } try { using (FileStream fs = new FileStream(path, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); fData = (HabitList)bf.Deserialize(fs); } } catch { } }