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(); }
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()); } }