标签:实例化 directory log 文件 c# events 路径 notify oid
using System.IO;
//首先实例化一个对象 FileSystemWatcher watcher = new FileSystemWatcher(); //设置监听路径 watcher.Path = Path.Combine(System.Environment.CurrentDirectory, @"eventTest\"); //只监听这一个文件,当礼品目录修改完毕后对此文件进行修改,由此触发监听事件 watcher.Filter = "EventConfig.ini"; watcher.NotifyFilter = NotifyFilters.LastWrite; //启用监听,如果不设置则不会触发事件 watcher.EnableRaisingEvents = true; //设置监听触发事件 watcher.Changed += new FileSystemEventHandler(watcher_Changed);
private void watcher_Changed(object sender, FileSystemEventArgs e) { WatchingEvent(EventConfigHelper.instance.WatchingNum); }
标签:实例化 directory log 文件 c# events 路径 notify oid
原文地址:http://www.cnblogs.com/oiliu/p/6963166.html