public HostsWatcher(IHostsParser parser, string path) { this.parser = parser; this.path = path; var directoryName = Path.GetDirectoryName(path); var fileName = Path.GetFileName(path); this.watcher = new FileSystemWatcher(directoryName, fileName); watcher.NotifyFilter = NotifyFilters.LastWrite; this.watcher.Changed += this.WatcherChanged; watcher.EnableRaisingEvents = true; }