Пример #1
0
        public static GameArchive ReadGame(int i)
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            using (FileStream fs = new FileStream("No." + i + ".sav", FileMode.Open))
            {
                GameArchive GameArchive = (GameArchive)binaryFormatter.Deserialize(fs);
                return(GameArchive);
            }
        }
Пример #2
0
        public static void SaveGame(int i, Game game)
        {
            GameArchive gameArchive = new GameArchive();

            gameArchive.Game     = game;
            gameArchive.SaveTime = DateTime.Now.ToString("yyyy-MM-dd\r\nHH:mm:ss");
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            using (FileStream fs = new FileStream("No." + i + ".sav", FileMode.Create))
            {
                binaryFormatter.Serialize(fs, gameArchive);
            }
        }