private void folderWatcherObect_Deleted(object sender, FileSystemEventArgs e) { if (this.InvokeRequired) { DirectoryWatcherEventDelegate d = new DirectoryWatcherEventDelegate(folderWatcherObect_Deleted); this.Invoke(d, new object[] { sender, e }); } else { UpdateSystemTrayIconTextAndIcon(); // Mise à jour des informations affichées. UpdateData(); } }
// Appelé lors de la détection de la création d'un fichier. private void folderWatcherObect_Created(object sender, FileSystemEventArgs e) { if (watchedFolderList.InvokeRequired) { DirectoryWatcherEventDelegate d = new DirectoryWatcherEventDelegate(folderWatcherObect_Created); Invoke(d, new object[] { sender, e }); } else { Debug.Assert(!InvokeRequired); UpdateSystemTrayIconTextAndIcon(); string watchedPath = ((FileSystemWatcher)sender).Path; string file = e.FullPath; if (Directory.Exists(file)) { file = file + Path.DirectorySeparatorChar; } // Prend en note le fichier ajouté. var newFile = new WatchedFile { Path = file, DateDetected = DateTime.Now, DirectoryWatched = watchedPath }; watchedFiles.Add(newFile); if (notificationType == NotificationType.TemporaryNotification) { // Faire apparaître une notification temporaire. String title = "Nouveaux fichiers"; String message = String.Format( "De nouveaux fichiers sont apparus dans le répertoire {0}.\n\n{1}", newFile.DirectoryName, newFile.FileName); notifyIcon.ShowBalloonTip(0, title, message, ToolTipIcon.Info); } else if (notificationType == NotificationType.PermanentNotification) { permanentNotificationForm.AddFile(newFile); } // Mise à jour des informations affichées. UpdateData(); } }