Beispiel #1
0
        /// <summary>
        /// Stops monitoring a folder. This disposes the Filewatcher and its events.
        /// </summary>
        private void StopMonitoringDirectory()
        {
            if (!fileSystemWatcher.IsNull())
            {
                fileSystemWatcher.Changed -= FileSystemWatcher_Changed;
                fileSystemWatcher.Created -= FileSystemWatcher_Created;
                fileSystemWatcher.Renamed -= FileSystemWatcher_Renamed;
                fileSystemWatcher.Deleted -= FileSystemWatcher_Deleted;

                fileSystemWatcher.Dispose();
                fileSystemWatcher = null;
            }
        }