public Func <string, bool> GetRetentionThresholdPredicate() { var timePeriod = _searchCriteria.GetTimePeriod(); var retentionThreshold = _searchCriteria.GetRetentionThreshold(); var resetRetentionTimePortion = _searchCriteria.GetResetRetentionTimePortion(); return(filePath => { try { if (retentionThreshold < 0) { return false; } if (retentionThreshold == 0) { return true; } if (timePeriod == TimePeriod.None) { return true; } var fileInfo = new FileInfo(filePath); var fileTimeRetention = GetRetentionDateOffset(timePeriod, retentionThreshold, resetRetentionTimePortion); var x = fileInfo.LastAccessTime < fileTimeRetention; return fileInfo.LastAccessTime < fileTimeRetention; } catch (Exception ex) { return false; } }); }