Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                HaltWithError(1, "Only one parameter is required, which must be a directory, where the files will be created.");
            }

            WatcherDirectory = String.Join(" ", args);
            if (!Directory.Exists(WatcherDirectory))
            {
                HaltWithError(2, $"The following directory does not exists: {WatcherDirectory}");
            }

#if !DEBUG
            var handle = GetConsoleWindow();
            ShowWindow(handle, Hide);
#endif

            FolderCleaner.Clean(WatcherDirectory);
            FileSystemChangeTrigger.WatchDirectory(WatcherDirectory);

            while (true)
            {
                Thread.Sleep(100);
            }
        }
Esempio n. 2
0
        private static void OnCreated(object source, FileSystemEventArgs e)
        {
            var key = e.Name.ToLower();

            if (Commands.ContainsKey(key))
            {
                var command = Commands[key];
                try
                {
                    command.Execute();
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ExceptionDetails.Get(ex));
                }
                var parent = Path.GetDirectoryName(e.FullPath);
#if DEBUG
                Thread.Sleep(30000);
#endif
                FolderCleaner.Clean(parent);
            }
        }