Giter Club home page Giter Club logo

fswatcher's Introduction

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.

fswatcher's People

Contributors

acken avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.