void watcher_Renamed(object sender, RenamedEventArgs e) { //File has been renamed, restart the watcher if (!WatchedPaths.Contains(e.OldFullPath)) { return; } UI.FileRemovedMessage msg = new UI.FileRemovedMessage(); msg.d1 = e.OldFullPath; msg.d2 = e.FullPath; msg.d3 = Backup.GetLastBackup(e.OldFullPath).DateTimeCreated.ToShortDateString() + " " + Backup.GetLastBackup(e.OldFullPath).DateTimeCreated.ToShortTimeString(); msg.Show(); while (msg.ActionSelected == "") { continue; } String result = msg.ActionSelected; msg.Close(); msg = null; if (result == "restore") { Backup.RestoreBackup(Backup.GetLastBackup(e.OldFullPath).ID, e.OldFullPath); } else { this.DisbleWatching(); watcher.Dispose(); watcher = new FileSystemWatcher(e.FullPath); this.EnableWatching(); } }
void watcher_Deleted(object sender, FileSystemEventArgs e) { //File has ben deleted if (!WatchedPaths.Contains(e.FullPath)) { return; } UI.FileDeletedMessage msg = new UI.FileDeletedMessage(); msg.d1 = fname(e.FullPath); msg.d2 = e.FullPath; var a = Backup.GetLastBackup(e.FullPath).DateTimeCreated; msg.d3 = a.ToShortDateString() + " " + a.ToShortTimeString(); msg.Show(); }