using System; | |
using System.IO; | |
namespace ConsoleApp | |
{ | |
public class SomeService | |
{ | |
private FileSystemWatcher _watcher; | |
public void OnStart() | |
{ | |
_watcher = new FileSystemWatcher(); | |
_watcher.Path = @"c:\temp"; | |
_watcher.NotifyFilter = NotifyFilters.LastWrite; | |
_watcher.Filter = "*.*"; | |
_watcher.Changed += new FileSystemEventHandler(OnChanged); | |
_watcher.EnableRaisingEvents = true; | |
} | |
private void OnChanged(object source, FileSystemEventArgs e) | |
{ | |
Console.WriteLine(e.Name); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var thing = new SomeService(); | |
thing.OnStart(); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment