8000 GitHub - kamukondiwa/NomNom: A windows service that provides a convinient hook into file creation events. Simply configure your monitors, create a new handler and recompile. :) · GitHub
[go: up one dir, main page]

Skip to content
kamukondiwaPublic

About

A windows service that provides a convinient hook into file creation events. Simply configure your monitors, create a new handler and recompile. :)

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

A simple windows service that allows for monitoring and consumption of file creation events. The service can be configured to monitor multiple file system locations and provides a simple api for adding new event handlers.

Step 1: Create a monitor.

<ArrayOfMonitor xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Monitor>
    <Name>
      Monitor 1
    </Name>
    <Source>\\NetworkLocation\Source</Source>
    <Destination>D:\local\Destination</Destination>
  </Monitor>
</ArrayOfMonitor>

Step 2: Add a handler

implement the IFileCreationEventHandler interface.

    public interface IFileCreationEventHandler {
        void Handle(Monitor monitor, Stream fileCreated, string filePath);
    }

Example : 

    public class FileCreationEventHandler : IFileCreationEventHandler {
        private readonly ILog log;

        public FileCreationEventHandler(ILog log) {
            this.log = log;
        }

        public void Handle(Monitor monitor, Stream fileCreated, string filePath) {
            const string messageFormat = "Monitor <{0}> has detected the creation of file <{1}>";
            this.log.Information(string.Format(messageFormat, monitor.Name, Path.GetFileName(filePath)));
        }
    }

About

A windows service that provides a convinient hook into file creation events. Simply configure your monitors, create a new handler and recompile. :)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0