public void Clean(string path, string fileExtension, DateTime?cutoffTime, long?maxSizeBytes) { if (!_ops.ExistsDirectory(path)) { return; } var found = _ops.FindFileInfo(path, p => IsMatchingLogFile(p, fileExtension)); if (cutoffTime.HasValue) { RemoveFiles(found, found.Keys, info => info.LastWriteTimeUtc < cutoffTime.Value); } if (maxSizeBytes.HasValue) { RemoveOldestFilesOverSizeLimit(found, maxSizeBytes.Value); } _ops.DeleteEmptyDirectories(path); }