| 发表于:2007-06-14 20:27:341楼 得分:0 |
filesystemwatcher控件就能实现你的功能,何必那么麻烦,性能还不一定好: imports system.io public class form1 private sub form1_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load filesystemwatcher1.path = "d:\temp " filesystemwatcher1.notifyfilter = io.notifyfilters.attributes or io.notifyfilters.creationtime or io.notifyfilters.directoryname or io.notifyfilters.filename or io.notifyfilters.lastaccess or io.notifyfilters.lastwrite or io.notifyfilters.security or io.notifyfilters.size addhandler filesystemwatcher1.changed, addressof onchanged addhandler filesystemwatcher1.created, addressof onchanged addhandler filesystemwatcher1.deleted, addressof onchanged addhandler filesystemwatcher1.renamed, addressof onrenamed filesystemwatcher1.enableraisingevents = true end sub private shared sub onchanged(byval source as object, byval e as filesystemeventargs) ' specify what is done when a file is changed, created, or deleted. console.writeline( "file: " & e.fullpath & " " & e.changetype) end sub private shared sub onrenamed(byval source as object, byval e as renamedeventargs) ' specify what is done when a file is renamed. console.writeline( "file: {0} renamed to {1} ", e.oldfullpath, e.fullpath) end sub end class | | |
|