A.Rocha skrev:
Hi,
sorry for only now i tell you that, but i'm working on compact framework
3.5 on windows Mobile 6.0, that's why i can't marke it as Serializable.
I have serialized several types of List<xxx> on compact framework without
any problems, but since it is a kind of structural data you have to
serialize/deserialize it as XML.
Use [XmlIgnore] on the line before the declaration of elements in your
class you don't want to serialize.
using System.Xml.Serialization;
...
private static void StoreObject(String file_name, object o)
{
if (o == null)
return;
String xml_file = String.Concat(Config.StorageDir, file_name);
Stream stream = null;
try
{
stream = File.Create(xml_file);
XmlSerializer xsz = new XmlSerializer(o.GetType());
xsz.Serialize(stream, o);
}
finally
{
if (stream != null)
stream.Close();
}
}
...
List<Customer> Customers;
...
StoreObject("Customers.xml", Customers);