public static ConfigTemplate ReadConfig() { ConfigTemplate ct; if (File.Exists(filename)) { FileStream fs = new FileStream(filename, FileMode.Open); try { XmlSerializer serializer = new XmlSerializer(typeof(ConfigTemplate)); ct = (ConfigTemplate)serializer.Deserialize(fs); } catch (Exception exp) { ct = new ConfigTemplate(); } finally { fs.Close(); } } else { ct = new ConfigTemplate(); } return ct; }
public static ConfigTemplate ReadConfig() { ConfigTemplate ct; if (File.Exists(filename)) { FileStream fs = new FileStream(filename, FileMode.Open); try { XmlSerializer serializer = new XmlSerializer(typeof(ConfigTemplate)); ct = (ConfigTemplate)serializer.Deserialize(fs); } catch (Exception exp) { ct = new ConfigTemplate(); } finally { fs.Close(); } } else { ct = new ConfigTemplate(); } return(ct); }
public static void WriteConfig(ConfigTemplate ct) { try { XmlSerializer serializer = new XmlSerializer(typeof(ConfigTemplate)); TextWriter writer = new StreamWriter(filename); serializer.Serialize(writer, ct); writer.Close(); } catch { } }
/// <summary> /// Writes the config. /// </summary> /// <param name="ct">The ct.</param> public static void WriteConfig(ConfigTemplate ct) { try { XmlSerializer serializer = new XmlSerializer(typeof(ConfigTemplate)); TextWriter writer = new StreamWriter(filename); serializer.Serialize(writer, ct); writer.Close(); } catch { } }