protected void CreateDocumentWatcher(string documentPath, string documentName)
{
LogManager.Debug("Creating Document Watcher Created for {0}\\{1}", documentPath, documentName);
if (!string.IsNullOrWhiteSpace(documentPath))
{
if (_fileWatcher == null)
_fileWatcher = new FileSystemWatcher();
_fileWatcher.Path = documentPath;
_fileWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName |
NotifyFilters.DirectoryName;
// Only watch for the loaded document.
_fileWatcher.Filter = documentName;
_fileWatcher.Changed += _fileWatcher_Changed;
_fileWatcher.Created += _fileWatcher_Changed;
_fileWatcher.Error+=delegate( object sender, ErrorEventArgs args ) { LogManager.Error( args.GetException() ); };
_fileWatcher.EnableRaisingEvents = true;
LogManager.Debug("Document Watcher Created for {0}\\{1}", documentPath, documentName);
}
}