Example #1
0
        public static void Save(string settingsFile, ref Settings settings)
        {
            try
             {
            if (settings == null)
               return;

            XmlWriterSettings xmlSettings = new XmlWriterSettings { Indent = true };
            using (XmlWriter writer = XmlWriter.Create(settingsFile, xmlSettings))
            {
               DataContractSerializer xml = new DataContractSerializer(typeof(Settings));
               xml.WriteObject(writer, settings);
            }
             }
             catch { }
        }
Example #2
0
 public static void Load(string settingsFile, ref Settings settings)
 {
     try
      {
     using (FileStream reader = new FileStream(settingsFile, FileMode.Open, FileAccess.Read))
     {
        DataContractSerializer xml = new DataContractSerializer(typeof(Settings));
        settings = xml.ReadObject(reader) as Settings;
     }
      }
      catch { }
      finally
      {
     if (settings == null)
        settings = new Settings();
      }
 }