Voila: j'ai mis au point deux petit script (save et load), les voici;
1 2 3 4 5 6 7 8 9 10 11 12 13
|
//scipt de sauvegarde
String SaveDeIP = mIP.Text;
String SaveDuPort = mPort.Value.ToString();
XmlTextWriter XTW = new XmlTextWriter("config.xml", System.Text.Encoding.UTF8);
XTW.WriteStartDocument();
XTW.WriteComment("Creation fichier XML test");
XTW.WriteStartElement("ConfigIP");
XTW.WriteElementString("IP", SaveDeIP);
XTW.WriteElementString("Port", SaveDuPort);
XTW.WriteEndElement();
XTW.Flush()
XTW.Close(); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
//chargement de donnée
try
{
XmlTextReader XTR = new XmlTextReader("config.xml");
String ServeurIP = XTR.ReadElementString();
mIP.Text = ServeurIP;
String Port = XTR.ReadElementString();
int ServPort = Convert.ToInt32(Port);
mPort.Value = ServPort;
XTR.Close();
}
catch
{
mIP.Text = "Pas de config";
mPort.Value = 0;
} |
Voila qui aidera qqcn je l'espère ^^
Le seul problème actuelle est dans le script de chargement, je ne peut pas charger un valeur choisi oO.
Exemple à la ligne:
String ServeurIP = XTR.ReadElementString("IP");
Mon compilateur m'insulte un petit-peut. Peut-être un mauvais choix de fonction ou de syntaxe Oo.
En tout cas merci de vôtres aide ^^
Partager