1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
InitializeComponent();
Humain toto = new Humain(25, "Toto");
Humain toto2;
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
/* serialisation */
/*Stream stream = new IsolatedStorageFileStream("serialisation.xml",FileMode.Create, FileAccess.Write, isf);
XmlSerializer serializer = new XmlSerializer(typeof(Humain));
TextWriter writer = new StreamWriter(stream);
serializer.Serialize(writer, toto);
writer.Close();*/
/* désérialisation */
Stream stream = new IsolatedStorageFileStream("serialisation.xml",FileMode.Open, FileAccess.Read, isf);
XmlSerializer serializer = new XmlSerializer(typeof(Humain));
TextReader reader = new StreamReader(stream);
toto2 = (Humain)serializer.Deserialize(reader);
label1.Content = toto2.nom;
button1.Content = toto2.nom; |