public static List <Player> LoadPlayerList() { string xmlData = File.ReadAllText(dataPath); List <Player> playerList = XMLConvert.XMLToObject(xmlData); return(playerList); }
public static void SavePlayer(Player player) { List <Player> playerList = LoadPlayerList(); playerList.Add(player); string xmlData = XMLConvert.ObjectToXml(playerList); File.WriteAllText(dataPath, xmlData); }
public static void SaveData(Player player) { List <Player> playerList = LoadPlayerList(); Player oldPlayer = playerList .FirstOrDefault(p => p.ID == player.ID); playerList.Remove(oldPlayer); playerList.Add(player); string xmlData = XMLConvert.ObjectToXml(playerList); File.WriteAllText(dataPath, xmlData); }