/// <summary> /// Обработчик изменения файлов на диске (Создание/Изменение/Удаление) /// </summary> private void Fsw_Changed(object sender, FileSystemEventArgs e) { var entry = new FSWatcherEntry { Path = e.FullPath }; FillLogEntry(entry, PathToSerial(e.FullPath)); switch (e.ChangeType) { case WatcherChangeTypes.Created: Console.WriteLine("Created: {0}", e.FullPath); entry.State = FILE_STATE.CREATED; break; case WatcherChangeTypes.Changed: Console.WriteLine("Changed: {0}", e.FullPath); entry.State = FILE_STATE.CHANGED; break; case WatcherChangeTypes.Deleted: Console.WriteLine("Deleted: {0}", e.FullPath); entry.State = FILE_STATE.REMOVED; break; } AddEntryToDatabase(entry); }
/// <summary> /// Обработчик переименования файла на диске /// </summary> private void Fsw_Renamed(object sender, RenamedEventArgs e) { var entry = new FSWatcherEntry(); FillLogEntry(entry, PathToSerial(e.FullPath)); Console.WriteLine("Renamed {0} to {1}", e.OldFullPath, e.FullPath); entry.State = FILE_STATE.RENAMED; entry.OldPath = e.OldFullPath; entry.Path = e.FullPath; AddEntryToDatabase(entry); }