void AddFileWatcher(LogFileInfo info) { var directoryName = Path.GetDirectoryName(info.File.FullName); if (directoryName != null) { var fileSystemWatcher = new FileSystemWatcher(directoryName) { Filter = info.File.Name }; fileSystemWatcher.Changed += LogFileChanged; fileSystemWatcher.Deleted += LogFileChanged; fileSystemWatcher.Created += LogFileChanged; fileSystemWatcher.Error += (sender, args) => { Console.WriteLine("Error"); }; fileSystemWatcher.NotifyFilter = fileSystemWatcher.NotifyFilter | NotifyFilters.Size; info.FileSystemWatcher = fileSystemWatcher; fileSystemWatcher.EnableRaisingEvents = true; fileSystemWatcher.IncludeSubdirectories = false; } }
void RemoveFileItems(LogFileInfo info) { var fileName = info.File.Name; m_AllItems.RemoveAll(item => (item.Filename == fileName)); }