-
-
Save benbhall/ec6e6264fa6d4386908139ab521a7835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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