VB.NET FileSystemWatcher的多个更改事件(VB.NET FileSystemWatcher Multiple Change Events)

   IT问题网   2018-05-27 00:00:00

问 题

我有以下的code:


进口system.io

公共类布拉赫
公共子新()
的initializecomponent()

昏暗的守望者作为新filesystemwatcher的("c:\")
watcher.enableraisingevents = true

addhandler的watcher.changed,addressof watcher_changed
结束小组

私人小组watcher_changed(byval发件人为对象,byval e上filesystemeventargs)
msgbox(e.fullpath)
结束小组
末级

当我运行它,并更改保存到一个文件在我的c盘,在code的伟大工程,但它执行watcher_changed()方法四次。知道为什么吗?中changetype是"4"的每一次。

感谢。

解决方案

从vs.net文档的"疑难解答filesystemwatcher的组件"部分...

生成一个动作中多创建活动

您可能会注意到单个创建事件生成由组件来处理多个创建的事件某些情况下。例如,如果使用filesystemwatcher组件来监控目录中创建新的文件,然后用记事本创建一个文件测试它,你可能会看到,即使是只创建一个单独的文件生成两个创建的事件。这是因为记事本进行在写作过程中多个文件系统操作。记事写入磁盘中所有创建该文件的内容,然后将文件属性批次。其他应用程序可以以相同的方式执行。由于filesystemwatcher的监控操作系统的活动,所有的事件,这些应用火将有所回升。

请注意:记事本也可能导致其他有趣的事件代。例如,如果您使用changeeventfilter指定您希望只为属性的变化看,然后你写的,你用记事本看目录中的文件,你会引发一个事件。这是因为,记事更新该操作期间该文件的存档的属性

标签:更改事件



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

光速VS NHibernate的(Lightspeed vs NHibernate)

problem what is the experience with lightspeedthe compari ...

实现在C#中的生产者/消费者模式(Implementing the Producer/Consumer Pattern in C#)

problem how can i implement the producer/consumer pattern ...

没有tnsnames.ora文件Oracle连接字符串(Oracle connection string without tnsnames.ora file)

problem i am using the .net framework with the system.dat ...

我如何可以访问WCF服务实例,在当前的背景下?(How do I get access to the WCF service instance in the current context)

problem if i am executing within the context of a particu ...

如何崩溃的.NET公共语言运行库(CLR)在纯.NET(How to crash the .NET common language runtime (CLR) in pure .net)

problem there is a similar question targeting the java vm ...

类/模型级别验证(而不是属性级别)? (ASP.NET MVC 2.0)(Class/Model Level Validation (as opposed to Property Level) (ASP.NET MVC 2.0))

problem basically, what the title says. i hav ...

为了避免出现InvalidOperationException最佳实践:集合已修改?(Best practice to avoid InvalidOperationException: Collection was modified)

problem very often i need something like that: foreach ...

为什么在C#4.0的可选参数需要编译时常?(Why do optional parameters in C# 4.0 require compile-time constants)

problem also is there a way to use run-time v ...

不能添加欣赏到EDMX(cannot add view to the edmx)

problem when trying to add a view to the edmx ...

目前已经在IP端点0.0.0.0:13000监听器。 ? (TCP使用WCF)(There is already a listener on IP endpoint 0.0.0.0:13000. (TCP using WCF))

problem i'm trying to figure out why the port is being us ...

这是使用System.Security.Principal.WindowsIdentity的合理的安全?(Is this use of System.Security.Principal.WindowsIdentity reasonably secure)

problem is system.security.principal.windowsidentity reas ...

C#拖放放大器;从列表框中下降到TreeView控件(C# Drag & drop from listbox to treeview)

problem i have a winform with a listbox and a treeview. ...

C#检查远程服务器(C# Check Remote Server)

problem can anyone advise what the best way to check (usi ...

如何获取数字HTTP状态codeS在PowerShell中(How to obtain numeric HTTP status codes in PowerShell)

problem i know of a few good ways to build web clients in ...

反映从基类的私人领域(Reflecting a private field from a base class)

problem here is the structure: myclass : superclass2 su ...

除通过JavaScript来本地磁盘作为.png文件渲染SVG图像(Save svg image rendered by a javascript to local disk as .png file)

problem i am new to svg and not an advanced user of javas ...

单元测试System.Timers.Timer的(unit testing system.timers.timer)

problem i've been reading over the questions about unit t ...

为什么String.IsNullOrEmpty比string.length减得快?(Why is String.IsNullOrEmpty faster than String.Length)

problem ilspy shows that string.isnullorempty is implemen ...

ASP.NET例外"正在中止线程"导致方法退出(ASP.NET exception "Thread was being aborted" causes method to exit)

problem in the code below, sometimes somefunc ...

如何通过在磁盘上真正大文件扫描?(How to scan through really huge files on disk)

problem considering a really huge file(maybe more than 4g ...