I think in your case the original loop For Eachwith If... Elsewould be a fairly simple approach
And loop a Stats.FoundFileonly once
For Each file As String In Stats.FoundFiles
Dim ftpFile As String = Utils.ToLowerWithoutSpaces(file)
If ftpFile.Contains(currentReportName) = True Then
Stats.MatchingFiles.Add(file)
Else
Stats.MismatchingFiles.Add(file)
End If
Next
Or, if you are a LINQ fan and should use it, you can play with Aggregatethe extension method
Stats.FoundFiles.Aggregate(String.Empty,
Function(seed, file)
If Utils.ToLowerWithoutSpaces(file).Contains(file) Then
Stats.MatchingFiles.Add(file)
Else
Stats.MismatchingFiles.Add(file)
End If
Return String.Empty
End Function)
Fabio source
share