public static void SaveObjectFile(ConfigFileContent thisObject, string filespec) { try { using (StreamWriter stream = new StreamWriter(filespec)) { XmlSerializer serializer = new XmlSerializer(typeof(ConfigFileContent)); serializer.Serialize(stream, thisObject); stream.Close(); } } catch (Exception ex) { throw ex; } }
public static ConfigFileContent LoadObjectFile(string filespec) { ConfigFileContent thisObject = null; try { using (StreamReader stream = new StreamReader(@filespec)) { XmlSerializer serializer = new XmlSerializer(typeof(ConfigFileContent)); thisObject = (ConfigFileContent)serializer.Deserialize(stream); stream.Close(); } } catch (Exception) { thisObject = new ConfigFileContent(); } return(thisObject); }