记录
//从类序列化为xml文件
List<Common.BrowserVersion> list = new List<Common.BrowserVersion>();
for (int i = 0; i < 10; i++)
{
Common.BrowserVersion mm = new Common.BrowserVersion();
mm.Name = i.ToString();
mm.Remark = i.ToString();
list.Add(mm);
}
System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(List<Common.BrowserVersion>));
using (System.IO.FileStream fs = new System.IO.FileStream(@"H:\aa.xml", System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
s.Serialize(fs, list);
}
//从xml文件反序列化为类
using (System.IO.StringReader rdr = new System.IO.StringReader(Common.Util.ReadData(@"H:\aa.xml")))
{
System.Xml.Serialization.XmlSerializer d = new System.Xml.Serialization.XmlSerializer(typeof(List<Common.BrowserVersion>));
List<Common.BrowserVersion> bvm = (List<Common.BrowserVersion>)d.Deserialize(rdr);
}