Search code examples
.netmodel-view-controllerfilesystemwatcher

Where do I put a FileSystemWatcher in my mvc application?


We have an asp.net mvc application that we would like to integrate a FileSystemWatcher with. I have seen many good examples on how to implement the FileSystemWatcher but I don't really know where to put it in my application. It seems like it should be started with the application. Any ideas?


Solution

  • Set it up in your Application_Start(). One of the best examples would be setting up log4net with ConfigureAndWatch(), which internally uses a FileSystemWatcher. Example:

    log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Server.MapPath("/log4net.config")))