Where can I put a FileSystemWatcher file in my mvc application?

We have an asp.net mvc application with which we would like to integrate FileSystemWatcher. I have seen many good examples of how to implement FileSystemWatcher, but I really don't know where to put it in my application. It looks like it should be running using the application. Any ideas?

+4
source share
2 answers

Install it in your Application_Start (). One of the best examples would be to create log4net with ConfigureAndWatch (), which internally uses FileSystemWatcher . Example:

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

You are probably better off using FileSystemWatcher in conjunction with the Windows Service if you want to control the file system for changes. The Windows service is constantly running, while the code in the web application is executed only in response to an HTTP request.

This article may be a good place to start.

+1
source

All Articles