Skip to content

Instantly share code, notes, and snippets.

@benbhall
Last active November 7, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbhall/ec6e6264fa6d4386908139ab521a7835 to your computer and use it in GitHub Desktop.
Save benbhall/ec6e6264fa6d4386908139ab521a7835 to your computer and use it in GitHub Desktop.
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