private void button1_Click(object sender, EventArgs e) { // Handle the button click event here }
private void OnChanged(object sender, FileSystemEventArgs e) { // Handle the file system change event here } // Create a new FileSystemWatcher and set its properties FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = "C:\\Temp"; watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Filter = "*.txt"; // Add the event listener to the FileSystemWatcher object watcher.Changed += new FileSystemEventHandler(OnChanged); // Start watching the specified directory watcher.EnableRaisingEvents = true;In this example, `OnChanged` is the event listener method that is called when a file is changed in the specified directory. It takes two parameters: `sender`, which is the object that raised the event (in this case, the FileSystemWatcher), and `e`, which contains information about the file system change (such as the file name and type of change). The package library used for handling events in C# is called `System.EventHandler`.