我不知道如何将我在 c# 上编写的代码与 FileSystemWatcher 类集成
public static void watcherFunc()
{
FileSystemWatcher fileWatcher = new FileSystemWatcher(@"C:\Documents and Settings\Develop\Desktop\test\");
fileWatcher.NotifyFilter = NotifyFilters.LastWrite;
fileWatcher.Changed += new FileSystemEventHandler(OnChanged);
fileWatcher.EnableRaisingEvents = true;
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
MessageBox.Show("File: " + e.FullPath + " " + e.ChangeType);
}
我试图在 form1 领先活动中调用它......我试图阅读如何做到这一点并在没有运气的情况下用谷歌搜索它请帮助......谢谢!