/// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (IsValidFile(e.FullPath))
     {
         try {
             Flow flow = new Flow(e.FullPath);
             if (this.Remove != null)
             {
                 this.Remove(this, new FlowWatcherEventArgs(flow));
             }
             if (this.Add != null)
             {
                 this.Add(this, new FlowWatcherEventArgs(flow));
             }
         }
         catch (StackOverflowException) {
             throw;
         }
         catch (OutOfMemoryException) {
             throw;
         }
         catch (ThreadAbortException) {
             throw;
         }
         catch (Exception x) {
             FlowWatcherException rwe = new FlowWatcherException("Error removing/adding flow after filesystem changed event", x);
             ExceptionManager.PublishException(rwe, "Error");
         }
     }
 }
 /// <summary>
 /// If directory is renamed, delete old flow and add first zip file found under directory.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DirectorySystemWatcher_Renamed(object sender, RenamedEventArgs e)
 {
     if (this.IsValidDirectory(e.FullPath))
     {
         try
         {
             Flow oldFlow = new Flow(Path.Combine(e.OldFullPath, "dummy.zip"));
             Flow newFlow = new Flow(Path.Combine(e.FullPath, "dummy.zip"));
             FlowWatcherRenameFlowIDEventArgs ea = new FlowWatcherRenameFlowIDEventArgs(oldFlow.FlowID, newFlow.FlowID, newFlow.Channel);
             if (this.RenameFlowID != null)
             {
                 this.RenameFlowID(this, ea);
             }
         }
         catch (StackOverflowException)
         {
             throw;
         }
         catch (OutOfMemoryException)
         {
             throw;
         }
         catch (ThreadAbortException)
         {
             throw;
         }
         catch (Exception x)
         {
             FlowWatcherException rwe = new FlowWatcherException("Error removing/adding flow after directory filesystem renamed event", x);
             ExceptionManager.PublishException(rwe, "Error");
         }
     }
     else if (this.IsValidChannelDirectory(e.FullPath))
     {
         try {
             FlowWatcherRenameChannelEventArgs rcea = new FlowWatcherRenameChannelEventArgs(Path.GetFileName(e.OldFullPath), Path.GetFileName(e.FullPath));
             if (this.RenameChannel != null)
             {
                 this.RenameChannel(this, rcea);
             }
         }
         catch (StackOverflowException) {
             throw;
         }
         catch (OutOfMemoryException) {
             throw;
         }
         catch (ThreadAbortException) {
             throw;
         }
         catch (Exception x) {
             FlowWatcherException rwe = new FlowWatcherException("Error renameing channel.", x);
             ExceptionManager.PublishException(rwe, "Error");
         }
     }
 }
 /// <summary>
 /// If reporid directory remove flow. If channel directory remove channel.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DirectorySystemWatcher_Deleted(object sender, FileSystemEventArgs e)
 {
     if (IsValidDirectory(e.FullPath))
     {
         try {
             Flow flow = new Flow(Path.Combine(e.FullPath, "dummy.zip"));
             FlowWatcherRemoveFlowIDEventArgs ea = new FlowWatcherRemoveFlowIDEventArgs(flow.FlowID, flow.Channel);
             if (this.RemoveFlowID != null)
             {
                 this.RemoveFlowID(this, ea);
             }
         }
         catch (StackOverflowException) {
             throw;
         }
         catch (OutOfMemoryException) {
             throw;
         }
         catch (ThreadAbortException) {
             throw;
         }
         catch (Exception x) {
             FlowWatcherException rwe = new FlowWatcherException("Error removing flow after directory filesystem deleted event", x);
             ExceptionManager.PublishException(rwe, "Error");
         }
     }
     else if (IsValidChannelDirectory(e.FullPath))
     {
         try {
             string channel = Path.GetFileName(e.FullPath);
             if (this.RemoveChannel != null)
             {
                 this.RemoveChannel(this, new FlowWatcherRemoveChannelEventArgs(channel));
             }
         }
         catch (StackOverflowException) {
             throw;
         }
         catch (OutOfMemoryException) {
             throw;
         }
         catch (ThreadAbortException) {
             throw;
         }
         catch (Exception x) {
             FlowWatcherException rwe = new FlowWatcherException("Error removing channel after directory filesystem deleted event", x);
             ExceptionManager.PublishException(rwe, "Error");
         }
     }
 }