日期:2014-05-18  浏览次数:20849 次

c#有没有监测功能的程序啊?
c#有没有监测功能的程序啊?
哪位老兄帮我写段监测功能的程序,也就是说这段程序能实现当这个程序文件的路径目录更改时它能自动启动运行,不用双击它的.exe文件!小弟急用,拜托各位大哥!

------解决方案--------------------
一看就想做坏事!
------解决方案--------------------
有个TIMER,到是判断一下就可以了
------解决方案--------------------
使用FileSystemWatcher类来监控 例如

FileSystemWatcher watcher = new FileSystemWatcher(@ "C:\windows ", "*.* ");
watcher.NotifyFilter = NotifyFilters.LastAccess;
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
watcher.EnableRaisingEvents = true;

…………

private void watcher_Changed(object sender, FileSystemEventArgs e)
{

s = "ChangeType :: " + e.ChangeType.ToString() + "\nFullPath :: " + e.FullPath.ToString() + "\n\n ";
MessageBox.Show(s);//

}
------解决方案--------------------
利用System.IO.FileSystemWatcher写成windows服务