public static ApplicationSettings Read(string configurationPath = "")
        {
            ApplicationSettings configuration = new ApplicationSettings();
            FileInfo            configurationFile;

            if (!String.IsNullOrWhiteSpace(configurationPath))
            {
                configurationFile = new FileInfo(configurationPath);
            }
            else
            {
                configurationFile = ConfigurationFile;
            }

            if (configurationFile.Exists)
            {
                XmlDocument document = new XmlDocument();
                document.Load(configurationFile.FullName);

                configuration.configPath = MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "configuration_path");
                configuration.LogLevel   = MCADCommon.LogCommon.Utils.ParseLogLevel(MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "log_level").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "log_level") : "info");

                Option <XmlElement> vaultElement = MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "vault_settings");
                configuration.VaultInfo = vaultElement.IsSome ? VaultSettings.Read(vaultElement.Get()).AsOption() : Option.None;

                Option <XmlElement> mailElement = MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "mail_settings");
                configuration.MailInfo = mailElement.IsSome ? MailSettings.Read(mailElement.Get(), PassPhrase).AsOption() : Option.None;


                configuration.ExcludePaths                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "exclude_paths", "path", false);
                configuration.IncludePaths                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_paths", "path", false);
                configuration.ExcludeFiles                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "exclude_files", "file", false);
                configuration.IncludeFiles                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_files", "file", false);
                configuration.IncludeFilePatterns         = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_patterns", "expression", false).Select(e => new Regex(e + "$", RegexOptions.IgnoreCase)).ToList();
                configuration.PossiblyLockedFiles         = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "possible_locked_files", "file", false);
                configuration.DeleteFiles                 = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "delete_files", "file", false);
                configuration.FolderMappings              = GetFolderMappings(MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "folder_mappings"));
                configuration.OutputPath                  = MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "output_path");
                configuration.OnlyRecreateFolderStructure = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "only_recreate_folders").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "only_recreate_folders").Equals("True", StringComparison.InvariantCultureIgnoreCase) : false;
                configuration.VersionToDownload           = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "version_to_download").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "version_to_download") : "latest";
                configuration.DownloadOnState             = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "download_on_state");
                configuration.NetworkRetries              = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "network_retries").IsSome ? Convert.ToInt32(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "network_retries")) : 5;

                if (VaultEagle.VaultUtils.HandleNetworkErrors(() => File.Exists(Path.Combine(configuration.configPath, "last_sync_time.txt")), configuration.NetworkRetries))
                {
                    try { configuration.LastSyncTime = DateTime.ParseExact(VaultEagle.VaultUtils.HandleNetworkErrors(() => File.ReadLines(Path.Combine(configuration.configPath, "last_sync_time.txt")).First(), configuration.NetworkRetries), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                    catch { configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                }
                else
                {
                    configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                }
            }
            else
            {
                configuration.configPath = "";
            }

            return(configuration);
        }
        public static ApplicationSettings Read()
        {
            ApplicationSettings configuration = new ApplicationSettings();

            if (ConfigurationFile.Exists)
            {
                XmlDocument document = new XmlDocument();
                document.Load(ConfigurationFile.FullName);

                configuration.ServerList = getServerList();


                configuration.configPath = Environment.ExpandEnvironmentVariables(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "configuration_path"));
                configuration.LogLevel   = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "log_level").IsSome ? MCADCommon.LogCommon.Utils.ParseLogLevel(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "log_level")).AsOption() : Option.None;

                Option <XmlElement> mailElement = MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "mail_settings");
                configuration.MailInfo = mailElement.IsSome ? MailSettings.Read(mailElement.Get(), PassPhrase).AsOption() : Option.None;
                configuration.MailLog  = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "mail_log").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "mail_log") : "Never";

                //   configuration.UseLastSyncDate = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "use_last_sync_date").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "use_last_sync_date").Equals("True", StringComparison.InvariantCultureIgnoreCase) : false;

                configuration.UseNotifications = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "use_notifications").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "use_notifications").Equals("True", StringComparison.InvariantCultureIgnoreCase) : false;

                configuration.NetworkRetries = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "network_retries").IsSome ? Convert.ToInt32(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "network_retries")) : 5;
                configuration.ReadOnly       = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "login_mode").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "login_mode").Equals("read", StringComparison.InvariantCultureIgnoreCase) : false;

                /*  if ((configuration.UseLastSyncDate) && (VaultEagle.VaultUtils.HandleNetworkErrors(() => File.Exists(Path.Combine(configuration.configPath, "last_sync_time.txt")), configuration.NetworkRetries)))
                 * {
                 *    try { configuration.LastSyncTime = DateTime.ParseExact(VaultEagle.VaultUtils.HandleNetworkErrors(() => File.ReadLines(Path.Combine(configuration.configPath, "last_sync_time.txt")).First(), configuration.NetworkRetries), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                 *    catch { configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                 * }
                 * else
                 *    configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                 */
                try{
                    configuration.SavedLogCount = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "saved_log_count").IsSome ? Convert.ToInt32(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "saved_log_count")) : 60;
                } catch {
                    configuration.SavedLogCount = 60;
                }
                return(configuration);
            }
            throw new ErrorMessageException("Could not find file: " + ConfigurationFile.FullName + ".");
        }