public FileNotificationService(FileInfo file, bool fullLines, int bufferTime, int intervalTime) { if (file == null) throw new ArgumentNullException("file"); if (!file.Exists) throw new ArgumentException("File does not exist."); this.fullLines = fullLines; FileSystemWatcher watcher = new FileSystemWatcher(file.DirectoryName, file.Name); this.io = new FileHandler(); this.Init(watcher, new[] { file }, bufferTime, intervalTime, null); }
public FileNotificationService(DirectoryInfo directory, bool fullLines, string filter, int bufferTime, int intervalTime, int maxDaysInactive) { if (directory == null) throw new ArgumentNullException("directory"); if (!directory.Exists) throw new ArgumentException("Directory does not exist."); this.fullLines = fullLines; var watcher = new FileSystemWatcher(directory.FullName, filter); IEnumerable<FileInfo> files = directory.EnumerateFiles(filter); Predicate<FileInfo> inactive = null; if (maxDaysInactive > 0) { inactive = f => f.LastWriteTimeUtc < DateTime.UtcNow.AddDays(maxDaysInactive * (-1)); } this.io = new FileHandler(); this.Init(watcher, files, bufferTime, intervalTime, inactive); }