-
-
Save benbhall/b2b4abcc0df20571ed0a17a0b65fce0d 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.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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
asas