public FSMonitor(fsmon.core FSMCORE, XmlNode CONFIGNODE) { //set config property configuration = CONFIG; //fsmon.MainClass.Log("Generating FileSystemMonitor Instance"); }
/************************************************ * METHODS ************************************************/ public FSMonitor(fsmon.Fsmon FSMON, XmlNode CONFIGNODE) { //set class properties this.fsmon = FSMON; this.confignode = CONFIGNODE; fsmon.Log("Configuring Watch Rule: '"+CONFIGNODE.Attributes["name"].Value+"'"); //set watch path try { fswatcher.Path = CONFIGNODE.Attributes["watchdir"].Value; } catch(Exception e) { fsmon.Log("Error Parsing Watch Rule 'watchdir' Attribute: "+string.Format ("{0}", e)); throw; } //set notify filters fswatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; //Set FS Callbacks fswatcher.Created += new FileSystemEventHandler(OnFSCreatedCallback); fswatcher.Deleted += new FileSystemEventHandler(OnFSDeletedCallback); fswatcher.Changed += new FileSystemEventHandler(OnFSChangedCallback); fswatcher.Renamed += new RenamedEventHandler(OnFSRenamedCallback); //enable event raise bool enableraisingevents = false; try { enableraisingevents = Convert.ToBoolean(CONFIGNODE.Attributes["enabled"].Value); } catch(Exception e) { fsmon.Log("Error Parsing Watch Rule 'enabled' Attribute: "+string.Format ("{0}", e)); throw; } fswatcher.EnableRaisingEvents = enableraisingevents; //include subdirectories or not bool includesubdirectories = false; try { includesubdirectories = Convert.ToBoolean(CONFIGNODE.Attributes["includesubdir"].Value); } catch(Exception e) { fsmon.Log("Error Parsing Watch Rule 'includesubdir' Attribute: "+string.Format ("{0}", e)); throw; } fswatcher.IncludeSubdirectories = includesubdirectories; //set fs filter fswatcher.Filter = CONFIGNODE.Attributes["filter"].Value; }