示例#1
0
        public static HabitList Initialize()
        {
            if (_habits == null)
            {
                _habits = new HabitList();
                Save.Load(ref _habits, _path);
            }

            return(_habits);
        }
示例#2
0
文件: Save.cs 项目: YourDeth/Traker_1
 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 { }
 }
示例#3
0
文件: Save.cs 项目: YourDeth/Traker_1
        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 { }
        }