Exemple #1
0
        private void SaveConfig()
        {
            CleanerConfig config = new CleanerConfig();

            //Ensure all rows are valid
            for (int i = _directoryRows.Count - 1; i >= 0; i--)
            {
                if (_directoryRows[i].IsDeleted)
                {
                    _directoryRows.RemoveAt(i);
                }
            }

            for (int i = 0; i < _directoryRows.Count; i++)
            {
                string path     = _directoryRows[i].Path;
                int    ageLimit = _directoryRows[i].AgeLimit;
                if (config.SearchedDirectories.Contains(new SearchedDirectory(path, ageLimit)) == false)
                {
                    config.SearchedDirectories.Add(new SearchedDirectory(path, ageLimit));
                }
            }

            config.BreakTime        = (int)breakTimeNumericUpDown.Value;
            config.PromptValue      = (int)decisionTimeNumericUpDown.Value;
            config.CombineTime      = (int)combineTimeNumericUpDown.Value;
            config.DelayedStart     = (int)delayNumericUpDown.Value;
            config.DeletionStrategy = (notifyEnabledCheckBox.Checked ? "Notify" : "None");
            config.DefaultKeep      = defaultActionComboBox.SelectedItem.ToString().Equals("Keep", StringComparison.OrdinalIgnoreCase);

            CleanerConfig.SaveConfigToFile(config, CleanerConfig.DEFAULT_CONFIG_PATH);
        }