public static bool Serializer<T>(object obj, string path) { FileStream xmlfile = new FileStream(path, FileMode.OpenOrCreate); //创建序列化对象 XmlSerializer xml = new XmlSerializer(typeof(T)); try { //序列化对象 xml.Serialize(xmlfile, obj); xmlfile.Close(); } catch (InvalidOperationException) { throw; } return true; }
联系客服