Skip to content

Instantly share code, notes, and snippets.

@benbhall

benbhall/ExampleOnCreated.cs Secret

Created Nov 7, 2017
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@sid-zupa sid-zupa commented Nov 11, 2019

asas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.