c# - FileSystemSafeWatcher 缺少已复制的文件
问题描述
我目前正在使用FileSystemSafeWatcher来克服由 File System Watcher 引起的问题。(参考:有没有一种简单的方法可以在 C# 中避免或停止 FileSystemWatcher 两次引发事件?)
当试图监视大约 400 个图像的复制事件的文件夹时,只会触发大约 300 个事件。文件可以从https://drive.google.com/file/d/1bcmQw4P79p9FCS2E0k_UKr5hKiQLZCgQ/view?usp=sharing下载
我不明白是什么导致了这个问题。
复制的事件
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)
{
}
}
}
挂钩到复制的事件
watcher = new FileSystemSafeWatcher(@watchpath);
watcher.ConsolidationInterval = 500;
watcher.EnableRaisingEvents = true;
watcher.Created += copied;
watcher.Changed += Watcher_Changed;
解决方案
推荐阅读
- asp.net - DEV-IIS 和 UAT-IIS 中缺少 loggerFactory 日志
- java - 创建一个返回测试结果的 selenium 测试方法 -java-
- azure-devops - 如何使用 Azure Git api 批准 PR
- webpack - 使用 Webpack 仅使用 Workbox 插件构建服务工作者代码 -> 无法指定用于预缓存的入口目录
- python - 用另一个类的条件语句附加一个类的列表属性?
- kubernetes - Kubernetes:挂载的文件是一个……目录?
- regex - 文件和非文件的 ASP.NET 5 正则表达式路由端点
- javascript - 为什么这个(双重)链表的弹出功能不起作用?
- javascript - 清理输入把手
- node.js - firebase firestore:执行类似 SQL 的连接