扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:microsoft 2007年11月10日
关键字:
'System.IO contains the 'file monitoring classes and types Imports System.IO Module Module1 Sub Main() 'FileSystemWatcher does the real work Dim fw As New FileSystemWatcher() 'WaitForChangedResult is what you 'get back when a change occurs Dim result As WaitForChangedResult 'set the path to monitor fw.Path = "C:\WINNT\" 'tell it whether to watch files or directories fw.Target = WatcherTarget.File 'tell it whether to include subdirs fw.IncludeSubdirectories = False 'hook up handlers AddHandler fw.Created,New FileSystemEventHandler(AddressOf OnFileNotify) 'enable the watcher fw.Enabled = True Do Console.WriteLine("Beginning to monitor") 'this is where we actually wait 'waiting blocks execution for the specified timeout result = fw.WaitForChanged(WatcherChangeTypes.All, 60000) Console.WriteLine("Hit Enter to continue q to quit") Loop While (Console.ReadLine <> "q") End Sub 'This is the delegate that gets 'called when a file is created Public Sub OnFileNotify(ByVal source As Object, ByVal e As FileSystemEventArgs) Console.WriteLine( "Notification received for file {0}, change type is {1}", _ e.FullPath, e.ChangeType) End Sub End Module |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者