コード例 #1
0
        /// <summary>
        /// Creates a <see cref="FileSystemWatcher"/>.
        /// </summary>
        /// <param name="path">The path to watch.</param>
        /// <param name="mode">The watch mode.</param>
        /// <param name="filter">The file search filter to use.</param>
        /// <returns>The created <see cref="FileSystemWatcher"/>.</returns>
        private BlueCollar.FileSystemWatcher CreateWatcher(string path, FileSystemWatcherMode mode, string filter)
        {
            BlueCollar.FileSystemWatcher watcher = null;

            try
            {
                watcher                     = new BlueCollar.FileSystemWatcher(path);
                watcher.Operation          += new FileSystemEventHandler(this.WatcherOperation);
                watcher.Mode                = mode;
                watcher.Filter              = filter;
                watcher.Threshold           = this.Threshold;
                watcher.EnableRaisingEvents = true;
            }
            catch
            {
                if (watcher != null)
                {
                    watcher.Dispose();
                }

                throw;
            }

            return(watcher);
        }
コード例 #2
0
        /// <summary>
        /// Creates a <see cref="FileSystemWatcher"/>.
        /// </summary>
        /// <param name="path">The path to watch.</param>
        /// <param name="mode">The watch mode.</param>
        /// <param name="filter">The file search filter to use.</param>
        /// <returns>The created <see cref="FileSystemWatcher"/>.</returns>
        private BlueCollar.FileSystemWatcher CreateWatcher(string path, FileSystemWatcherMode mode, string filter)
        {
            BlueCollar.FileSystemWatcher watcher = null;

            try
            {
                watcher = new BlueCollar.FileSystemWatcher(path);
                watcher.Operation += new FileSystemEventHandler(this.WatcherOperation);
                watcher.Mode = mode;
                watcher.Filter = filter;
                watcher.Threshold = this.Threshold;
                watcher.EnableRaisingEvents = true;
            }
            catch
            {
                if (watcher != null)
                {
                    watcher.Dispose();
                }

                throw;
            }

            return watcher;
        }