Hi,一个FileSystemWatcher的问题
Hi,大家好,我在用FileSystemWatcher监视某个目录的时候出现了问题,在往被监视的目录拷贝文件的时候Create事件似乎不能被触发(请看下面的程序),我把一个txt文件从C盘的根目录拷贝到C:\ABC目录下,但是并没有触发事件,弹出消息框,请问是怎么回事,谢谢!-------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim watcher As New FileSystemWatcher
watcher.Path = "C:\ABC"
watcher.NotifyFilter = (NotifyFilters.Attributes Or NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.CreationTime Or NotifyFilters.Size)
watcher.Filter = "*.txt"
AddHandler watcher.Created, AddressOf OnChanged
'AddHandler watcher.Changed, AddressOf OnChanged
'AddHandler watcher.Deleted, AddressOf OnChanged
'AddHandler watcher.Renamed, AddressOf OnRenamed
watcher.EnableRaisingEvents = True
End Sub
Sub OnChanged(ByVal sender As Object, ByVal e As FileSystemEventArgs)
MessageBox.Show("test")
End Sub --------------------编程问答-------------------- 啊?CSDN现在人气这么差啊?都没有关注一下? --------------------编程问答-------------------- http://topic.csdn.net/u/20071216/11/6426c72a-dc33-472e-a254-f175180dccd4.html --------------------编程问答-------------------- http://topic.csdn.net/u/20071216/11/6426c72a-dc33-472e-a254-f175180dccd4.html --------------------编程问答-------------------- http://topic.csdn.net/u/20071216/11/6426c72a-dc33-472e-a254-f175180dccd4.html --------------------编程问答-------------------- 我又试了一下,按照MSDN上写控制台程序就可以,但是现在我需要用窗体程序啊。请问怎么解决 --------------------编程问答-------------------- 'AddHandler watcher.Changed, AddressOf OnChanged
这个,你不要注释掉。
补充:.NET技术 , VB.NET