public static void SerilizeXml(RequestList data, string path) { System.IO.FileStream stream = new FileStream(path, FileMode.Create); try { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(RequestList)); serializer.Serialize(stream, data); } catch (Exception ex) { log.ErrorFormat("SerilizeAnObject Exception: {0}", ex.Message); } finally { stream.Close(); stream.Dispose(); } }
public static RequestList DeserilizeXml(string path) { RequestList data = null; System.IO.FileStream stream = new FileStream(path, FileMode.Open); try { System.Xml.XmlReader reader = new XmlTextReader(stream); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(RequestList)); data = (RequestList)serializer.Deserialize(reader); } catch (Exception ex) { log.ErrorFormat("DeserilizeAnObject Exception: {0}", ex.Message); } finally { stream.Close(); stream.Dispose(); } return(data); }