So I've got a bit of a problem I'm made a class that i have to use 7 times (one for each day of the week) I have the serialize set this way
FileStream stream = new FileStream("C:\\employee.xml", FileMode.OpenOrCreate); XmlSerializer serializer = new XmlSerializer(typeof(Day)); serializer.Serialize(stream, monday); serializer.Serialize(stream, tuesday); serializer.Serialize(stream, wednesday); serializer.Serialize(stream, thursday); serializer.Serialize(stream, friday); serializer.Serialize(stream, saturday); serializer.Serialize(stream, sunday);
|
problem is when I unserialize it only works if i only save the class once, is there anything that has to be done differently for more then 1 instance of the same class?
FileStream stream = new FileStream("C:\\employee.xml", FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(Day)); monday = (Day)serializer.Deserialize(stream);
|
Thanks :)
Pasan RatnayakePosted Sep 2, 2010, 1:32 AM
AdamPosted Aug 31, 2010, 1:37 PM
MarcoPosted Aug 31, 2010, 1:18 PM
AdamPosted Aug 31, 2010, 1:09 PM
Off the top of my head I would say that you are overwriting the data in your stream each time you call Serialize() in your code sample. Based on your code you will end up with sunday only serialized and written to the file.
Adam