using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Xml.Serialization; namespace TheGameExtreme.IO { class IOGamePreparation { static string pathPlayers = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NbPlayers.xml"); public static void SaveParamaterGamePreparation(int nbPlayers) { XmlSerializer ser = new XmlSerializer(typeof(int)); TextWriter tw = new StreamWriter(pathPlayers); ser.Serialize(tw, nbPlayers); tw.Close(); } public static int LoadParameterGamePreparation() { XmlSerializer xs = new XmlSerializer(typeof(int)); try { using (FileStream fs = new FileStream(pathPlayers, FileMode.Open)) { int players = (int)xs.Deserialize(fs); return players; } } catch { return 0; } } } }