Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Load config
            CleanerConfig config = CleanerConfig.ParseConfig(CleanerConfig.DEFAULT_CONFIG_PATH);

            Thread.Sleep(config.DelayedStart * 1000 * 60);

            //Create cleaner
            DirectoryCleaner cleaner = new DirectoryCleaner();

            cleaner.SetConfig(config);
            cleaner.Start();

            //Update cleaner if config changes
            ConfigWatcher watcher = null;

            watcher = new ConfigWatcher("CleanerSettings.xml", delegate {
                Console.WriteLine("Config Changed!");
                watcher.Stop();
                cleaner.Stop();
                CleanerConfig newConfig = CleanerConfig.ParseConfig(CleanerConfig.DEFAULT_CONFIG_PATH);
                cleaner.SetConfig(newConfig);
                cleaner.Start();
                watcher.Start();
            });
            watcher.Start();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public CleanerSettingsApplication()
        {
            InitializeComponent();

            CleanerConfig config = CleanerConfig.ParseConfig(CleanerConfig.DEFAULT_CONFIG_PATH);

            if (config == null)
            {
                config = CleanerConfig.DefaultConfig;
            }

            //Load in config
            for (int i = 0; i < config.SearchedDirectories.Count; i++)
            {
                AddTableEntry();
                _directoryRows[i].SetRowValues(config.SearchedDirectories[i].Path, config.SearchedDirectories[i].FileAgeLimit);
            }
            notifyEnabledCheckBox.Checked       = config.DeletionStrategy.Equals("Notify", StringComparison.OrdinalIgnoreCase);
            breakTimeNumericUpDown.Value        = config.BreakTime;
            combineTimeNumericUpDown.Value      = config.CombineTime;
            delayNumericUpDown.Value            = config.DelayedStart;
            decisionTimeNumericUpDown.Value     = config.PromptValue;
            defaultActionComboBox.SelectedIndex = config.DefaultKeep ? 0 : 1;
        }