FileSystemSafeWatcher Missing Files Copied

筅森魡賤 提交于 2019-12-11 15:28:23

问题


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;

来源:https://stackoverflow.com/questions/57444370/filesystemsafewatcher-missing-files-copied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!