static void writeXML(List<Shape> shapes, string path) { Record rec = new Record(); rec.shapes = shapes; System.IO.FileStream f = new System.IO.FileStream(path, System.IO.FileMode.Create); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Record)); foreach (Shape sh in shapes) { serializer.Serialize(f, sh); } f.Close(); }