FileSystemSafeWatcher Missing Files Copied

2019-08-22 02:21发布

I'm currently using FileSystemSafeWatcher to overcome issues caused by File System Watcher. (Ref:Is there a simple way to avoid or stop FileSystemWatcher raise event twice in C#?)

When trying to monitor a folder for copied event of around approx 400 images,Only approx 300 events are triggered.Files can be downloaded from https://drive.google.com/file/d/1bcmQw4P79p9FCS2E0k_UKr5hKiQLZCgQ/view?usp=sharing

I cannot understand what causes this issue.

Copied event

void copied(object sender, FileSystemEventArgs e)
        {
       // Printing to check if the If condition causes the issue
       System.Diagnostics.Debug.WriteLine("||| > " + robotprocesslist.Count);

   if (ImageExtensions.Contains(Path.GetExtension(e.FullPath).ToUpperInvariant()))
            {
              try
                {

                    if (processedfiles.Any(sublist => sublist.Contains(e.FullPath)) == true)
                    {
                        processedfiles.Remove(e.FullPath);
                    }
                    robotprocesslist.Add(e.FullPath);
                    System.Diagnostics.Debug.WriteLine("--> " + robotprocesslist.Count);


                }
                catch (Exception error)
                {

                }


            }

        }

Hooking to the Copied Event

 watcher = new FileSystemSafeWatcher(@watchpath);
 watcher.ConsolidationInterval = 500;
 watcher.EnableRaisingEvents = true;
 watcher.Created += copied;
 watcher.Changed += Watcher_Changed;

0条回答
登录 后发表回答