示例#1
0
        private FileNotificationService CreateWatcher(IWatchConfiguration configuration)
        {
            var info = new FileInfo(configuration.Path);
            FileNotificationService watcher = null;

            if (info.Attributes.HasFlag(FileAttributes.Directory))
            {
                DirectoryInfo directory = new DirectoryInfo(configuration.Path);

                if (directory.Exists)
                {
                    watcher = new FileNotificationService(
                        directory,
                        true,
                        configuration.Filter ?? "*",
                        configuration.BufferTime,
                        configuration.IntervalTime,
                        configuration.MaxDaysInactive);
                }
            }
            else if (info.Exists)
            {
                watcher = new FileNotificationService(info, true, configuration.BufferTime, configuration.IntervalTime);
            }

            return(watcher);
        }
示例#2
0
        private FileNotificationService CreateWatcher(IWatchConfiguration configuration)
        {
            var info = new FileInfo(configuration.Path);
            FileNotificationService watcher = null;

            if (info.Attributes.HasFlag(FileAttributes.Directory))
            {
                DirectoryInfo directory = new DirectoryInfo(configuration.Path);

                if (directory.Exists)
                {
                    watcher = new FileNotificationService(
                        directory,
                        true,
                        configuration.Filter ?? "*",
                        configuration.BufferTime,
                        configuration.IntervalTime,
                        configuration.MaxDaysInactive);
                }
            }
            else if (info.Exists)
            {
                watcher = new FileNotificationService(info, true, configuration.BufferTime, configuration.IntervalTime);
            }

            return watcher;
        }