XmlSerializer serializer = new XmlSerializer(typeof(Zawodnik[]));
// Create a FileStream to write with.
Stream writer = new FileStream(@”c:\dane\aa.xml”, FileMode.Create);
// Serialize the object, and close the TextWriter
serializer.Serialize(writer, zawodnicy);
writer.Close();
StreamReader reader = new StreamReader(@”c:\dane\aa.xml”);
var a = (Zawodnik[])serializer.Deserialize(reader);
reader.Close();
binary
// Serialize object.
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(„Person.bin”, FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, zawodnicy);
stream.Close();
// Deserialize object.
Stream readStream = new FileStream(„Person.bin”, FileMode.Open, FileAccess.Read, FileShare.Read);
var p2 = (Zawodnik[])formatter.Deserialize(readStream);
readStream.Close();