Пример #1
0
        public static void SaveSnakeBot(BotSnake snake)
        {
            BinaryFormatter bf     = new BinaryFormatter();
            FileStream      stream = new FileStream(Application.LocalUserAppDataPath + "\\config.snakeBotData", FileMode.Create);
            SnakeBotData    data   = new SnakeBotData(snake);

            bf.Serialize(stream, data);
            stream.Close();
        }
Пример #2
0
 public static SnakeBotData LoadSnakeBot()
 {
     if (File.Exists(Application.LocalUserAppDataPath + "\\config.snakeBotData"))
     {
         BinaryFormatter bf     = new BinaryFormatter();
         FileStream      stream = new FileStream(Application.LocalUserAppDataPath + "\\config.snakeBotData", FileMode.Open);
         SnakeBotData    data   = bf.Deserialize(stream) as SnakeBotData;
         stream.Close();
         return(data);
     }
     else
     {
         return(new SnakeBotData());
     }
 }