using BitPlus.IO.Directory.Watcher; internal class Program { private static void Main(string[] args) { var path = args.Length > 0 ? args[0] : null; while (string.IsNullOrWhiteSpace(path) || !Directory.Exists(path)) { Console.Write("감시할 폴더 경로를 입력하세요(Enter the folder path to monitor.): "); path = Console.ReadLine(); if (string.IsNullOrWhiteSpace(path)) Console.WriteLine("경로가 비어 있습니다.(The path is empty.)"); else if (!Directory.Exists(path)) Console.WriteLine("폴더가 존재하지 않습니다.(The folder does not exist.)"); } using var watcher = new DirectoryWatcher(path); watcher.FileCreated += (_, e) => Console.WriteLine($"[CREATE] {e.FullPath}"); watcher.FileChanged += (_, e) => Console.WriteLine($"[CHANGE] {e.FullPath}"); watcher.FileDeleted += (_, e) => Console.WriteLine($"[DELETE] {e.FullPath}"); watcher.FileRenamed += (_, e) => Console.WriteLine($"[RENAME] {e.OldFullPath} -> {e.FullPath}"); watcher.WatcherError += (_, e) => Console.WriteLine($"[ERROR] {e.GetException().Message}"); watcher.Start(); Console.WriteLine($"감시 시작(Start the surveillance): {path}"); Console.WriteLine("종료하려면 Enter를 누르세요...(Press Enter to exit)"); Console.ReadLine(); watcher.Stop(); } }