public static void LoadSettings(out ClientSettings o) { o = null; FileStream stream = null; try { XmlSerializer xml = new XmlSerializer(typeof(ClientSettings)); stream = new FileStream(Application.StartupPath + @"\QClient.config", FileMode.Open); o = (ClientSettings)xml.Deserialize(stream); } catch (Exception) { } finally { if (stream != null) { stream.Close(); } } }
public static bool SaveSettings(ClientSettings o) { bool res = true; StreamWriter writer = null; try { XmlSerializer xml = new XmlSerializer(o.GetType()); writer = new StreamWriter(Application.StartupPath + @"\QClient.config"); xml.Serialize(writer, o); } catch (Exception) { res = false; } finally { if (writer != null) { writer.Close(); } } return res; }