//::::::::::::::::::::::::::::::::: private void loadConfigFile() { XmlTextReader reader = new XmlTextReader(ConfigPath); try { reader.Read(); _configFileDoc = new XmlDocument(); _configFileDoc.Load(reader); checkConfigFile(_configFileDoc); reader.Close(); } catch (Exception exc) { reader.Close(); ReBuildConfigFile(); _configError = ConfigFileError.InvalidFile; _configErrorStr = string.Format(@"Invalid Configuration File. The current file has been renamed. A Default Configuration File has been created. Reason[{0}]", exc.Message); } }
//................................. public void initConfigFileManager() { try { if (!Directory.Exists(_configFolder)) // Config Folder does not exitst { Directory.CreateDirectory(_configFolder); CreateDefaultConfigFile(); if (notifNewConfigFileCreatedFunc != null) { notifNewConfigFileCreatedFunc(); } } else { if (!File.Exists(ConfigPath)) // Config File does not exitst { CreateDefaultConfigFile(); if (notifNewConfigFileCreatedFunc != null) { notifNewConfigFileCreatedFunc(); } } else { try { loadConfigFile(); if (double.Parse(_configFileDoc.DocumentElement.Attributes[@"Version"].Value) < double.Parse(_version)) { _singletonLogger.LogWarning(@"An older Config File's version has been detected. A new Config File will be create. The current one will be renamed."); SiteIDMap[] siteIDMap = SiteIDMapInfo; ReBuildConfigFile(); SiteIDMapInfo = siteIDMap; if (notifNewConfigFileCreatedFunc != null) { notifNewConfigFileCreatedFunc(); } } else { if (notifConfigFileLoadedFunc != null) { notifConfigFileLoadedFunc(_configError, _configErrorStr); } } } catch (Exception) { if (notifConfigFileLoadFailedFunc != null) { notifConfigFileLoadFailedFunc(_configError, _configErrorStr); } } } } } catch (Exception e) { _configError = ConfigFileError.InvalidFile; _configErrorStr = string.Format(@"Creating Config file folder", e.Message); if (notifConfigFileLoadFailedFunc != null) { notifConfigFileLoadFailedFunc(_configError, _configErrorStr); } } }