Skip to content

Instantly share code, notes, and snippets.

@benbhall
Created November 7, 2017 21:10
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/b2b4abcc0df20571ed0a17a0b65fce0d to your computer and use it in GitHub Desktop.
Save benbhall/b2b4abcc0df20571ed0a17a0b65fce0d 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.FileName;
_watcher.Filter = "*.*";
_watcher.Created += new FileSystemEventHandler(OnCreated);
_watcher.EnableRaisingEvents = true;
}
private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine(e.Name);
}
}
class Program
{
static void Main(string[] args)
{
var thing = new SomeService();
thing.OnStart();
Console.ReadLine();
}
}
}
@sid-zupa
Copy link

asas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment