You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

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