コード例 #1
0
 private static void DeviceWatcher_DeviceQueryRemove(object sender, DeviceNotificationEventArgs e)
 {
     if (DirectoryWatchers.ContainsKey(e.Name))
     {
         DirectoryWatchers[e.Name].Stop();
     }
 }
コード例 #2
0
        private static void DeviceWatcher_DeviceArrived(object sender, DeviceNotificationEventArgs e)
        {
            if (DirectoryWatchers.ContainsKey(e.Name))
            {
                DirectoryWatchers[e.Name].Start();
            }
            else
            {
                RegisterDirectoryWatcher(e.Name);
            }

            SendNotificationMessage(NotificationType.Add, e.Name);
        }
コード例 #3
0
        public static void RegisterDirectoryWatcher(string path)
        {
            DirectoryWatcher directoryWatcher = new DirectoryWatcher(path, OnFileEvent, OnError);

            directoryWatcher.Start();

            if (DirectoryWatchers.ContainsKey(path))
            {
                DirectoryWatchers[path].Stop();
                DirectoryWatchers.Remove(path);
            }

            DirectoryWatchers.Add(path, directoryWatcher);
        }