Skip to content

acken/FSWatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A cross platform file system watcher for .Net and Mono

FSWatcher uses various strategies to solve the nightmare that is
file system events. It uses a variation of native events and
raw polling determined by what is available.
The native .Net file system watcher is completely unreliable with
it's overflow exceptions. FSWatcher solves that and makes sure you
are notified about all file system changes.

Getting started
After cloning this repository run deploy.bat if you are on windows
or deploy.sh if you are on Linux or MacOSX. When deploy is done
you will find the binary files in the ReleaseBinaries directory.
FSWatcher.Console.exe is just a command line utility.

Reference FSWatcher.dll in your project and use the following code
to start listening for file system events:

	var watcher = 
		new Watcher(
			watch_directory,
			(s) => Console.WriteLine("Directory created " + s),
			(s) => Console.WriteLine("Directory deleted " + s),
			(s) => Console.WriteLine("File created " + s),
			(s) => Console.WriteLine("File changed " + s),
			(s) => Console.WriteLine("File deleted " + s));
	watcher.Watch();
	....
	watcher.StopWatching();

Additional features is manually setting the polling frequency. By
default it is set to 4 times the time it takes to create a file
system snapshot of the directory that is being watched. There are
also properties showing watcher strategies:

	var settings = watcher.Settings;
	// Overriding the polling frequency in milliseconds
	settings.SetPollFrequencyTo(10000);

	// Chosen strategy
	// Are we polling continuously
	settings.ContinuousPolling

	// What events are we provided with automatically
	// If not provided automatically we rely on polling
	settings.CanDetectEventedDirectoryCreate
	settings.CanDetectEventedDirectoryDelete
	settings.CanDetectEventedDirectoryRename
	settings.CanDetectEventedFileCreate
	settings.CanDetectEventedFileChange
	settings.CanDetectEventedFileDelete
	settings.CanDetectEventedFileRename

Look at the FSWatcher.Console/Program.cs for a working sample.

FSWatcher is licensed under the MIT license.

About

Cross platform multi-strategy file system watcher

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published