Ejemplo n.º 1
0
 static LocalSettings()
 {
     LocalSettings.VersionDataFilePath = LocalSettings.DataPath + "\\version.dat";
     if (!Directory.Exists(LocalSettings.DocumentPath))
     {
         Directory.CreateDirectory(LocalSettings.DocumentPath);
     }
     if (!Directory.Exists(LocalSettings.AddonPath))
     {
         Directory.CreateDirectory(LocalSettings.AddonPath);
     }
     if (!Directory.Exists(LocalSettings.DataPath))
     {
         Directory.CreateDirectory(LocalSettings.DataPath);
     }
     if (!Directory.Exists(LocalSettings.UserPath))
     {
         Directory.CreateDirectory(LocalSettings.UserPath);
     }
     LocalSettings.LoadSettings();
 }
Ejemplo n.º 2
0
        public static void LoadSettings()
        {
            LocalSettings._settingsObject = new SettingsObject();
            string settingsFileName = LocalSettings.SettingsFileName;
            string text             = Path.Combine(Path.GetDirectoryName(LocalSettings.SettingsFileName), Path.GetFileNameWithoutExtension(LocalSettings.SettingsFileName) + "_Backup.txt");

            if (File.Exists(settingsFileName))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(LocalSettings._settingsObject.GetType());
                XmlTextReader xmlTextReader = new XmlTextReader(settingsFileName);
                try
                {
                    LocalSettings._settingsObject = (xmlSerializer.Deserialize(xmlTextReader) as SettingsObject);
                }
                catch
                {
                    xmlTextReader.Close();
                    if (File.Exists(text))
                    {
                        File.Delete(settingsFileName);
                        File.Copy(text, settingsFileName);
                        File.Delete(text);
                        LocalSettings.LoadSettings();
                        return;
                    }
                }
                xmlTextReader.Close();
                try
                {
                    File.Copy(settingsFileName, text, true);
                }
                catch (Exception)
                {
                }
            }
            if (LocalSettings.DefaultRecordLimit == 0)
            {
                LocalSettings.DefaultRecordLimit = 100;
            }
        }