FileSystemWatcher的事件触发的问题(S) [英] FileSystemWatcher event trigger problem(s)

查看:297
本文介绍了FileSystemWatcher的事件触发的问题(S)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是,FileSystemWatcher的触发事件不止一次。这里是我的设置;

It seems like , FileSystemWatcher triggers events more than once. Here is my settings ;

 watcher = new FileSystemWatcher();
 watcher.Path = @"D:\testSpace";
 watcher.InternalBufferSize = 1024*64;
 watcher.Deleted += Triggered;
 watcher.Changed += Triggered;
 watcher.Created += Triggered;
 watcher.Error += ErrorOccured;
 watcher.NotifyFilter = NotifyFilters.LastWrite;
 watcher.IncludeSubdirectories = true;

 watcher.EnableRaisingEvents = true; 

  • 如果您更改文档,文件更改事件触发两次。

    • If you change a document , Document changed event triggered twice.

      新创建的事件不被触发,除非该文件夹下创建一个新的文件。文件夹

      New folder created event does not get triggered unless a new file created under the folder.

      删除事件不会触发(使用移删除,以及尝试)

      Deleted event not fired ( tried using shift delete as well)

      做你们知道的任何工作,围绕这些问题?

      do you guys know any work around for these issues ?

      推荐答案

      FileSystemWatcher的

      通用文件系统操作可能   提高多个事件。对于   例如,当一个文件从一个移动   目录到另一个,几   并调用onChanged一些OnCreated和   OnDeleted事件可能得到提升。   移动一个文件是一个复杂的操作   它由多个简单的   操作,因此,提高多   事件。同样地,某些应用   (例如防病毒软件)   可能会导致额外的文件系统   是由检测到的事件   FileSystemWatcher的。

      Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.

      解决您的第一个问题,在链接描述。

      The solution to your 1st issue is described in the link.

      这篇关于FileSystemWatcher的事件触发的问题(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆