public static WatchLog Create(string path, FileSystemEventArgs e) { var log = new WatchLog(); log.Path = path; log.Name = System.IO.Path.GetFileName(path); log.EventName = e.ChangeType.ToString(); log.FilePath = e.FullPath; log.FileName = e.Name; log.Date = DateTime.Now; if (e is RenamedEventArgs renamed) { log.BeforeFilePath = renamed.OldFullPath; log.BeforeFileName = renamed.OldName; } else { log.BeforeFilePath = string.Empty; log.BeforeFileName = string.Empty; } return(log); }
private void OnDeleted(object sender, FileSystemEventArgs e) { WatchLog log = WatchLog.Create(Path, e); Dispatcher.Invoke(() => Logs.Insert(0, log)); }
private void OnRenamed(object sender, RenamedEventArgs e) { WatchLog log = WatchLog.Create(Path, e); Dispatcher.Invoke(() => Logs.Insert(0, log)); }