Esempio n. 1
0
 void FileService_FileMoved(object sender, FileCopyEventArgs e)
 {
     foreach (var file in e)
     {
         if (watchers.TryGetValue(file.SourceFile, out FileSystemWatcher watcher))
         {
             ContextFileMoved?.Invoke(this, new ContextFileMovedEventArgs(file.SourceFile, file.TargetFile));
             watcher.Dispose();
             watchers.Remove(file.SourceFile);
             StartWatching(file.TargetFile.FileName, file.TargetFile.ParentDirectory);
         }
     }
 }
 void FileService_FileMoved(object sender, FileCopyEventArgs e)
 {
     lock (watchedFiles) {
         foreach (var file in e)
         {
             if (watchedFiles.Remove(file.SourceFile))
             {
                 ContextFileMoved?.Invoke(this, new ContextFileMovedEventArgs(file.SourceFile, file.TargetFile));
                 if (file.SourceFile == file.TargetFile)
                 {
                     StartWatching(file.TargetFile.FileName, file.TargetFile.ParentDirectory);
                 }
             }
         }
     }
 }