Beispiel #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();
        }
Beispiel #2
0
        /// <summary>
        /// Creates a blank directory cleaner
        /// </summary>
        public DirectoryCleaner()
        {
            //Establish singleton
            if (Instance == null)
            {
                Instance = this;
            }

            _itemsForDeletion = new List <DeletableItem>();
            _whiteList        = new FileWhiteList();
        }