In this short post we’ll see how create a simple predicate class to use with FindAll.
The following code lists all files presents into a directory and filters only with by “txt” extension.

    Sub testPredicate()
        'take all file
        Dim Allfiles As String() = Directory.GetFiles("C:\ProgramData\yourdiroctory\")
        'take file wit .txt extension
        Dim filteredfiles As List(Of String) = Allfiles.ToList.FindAll(AddressOf New Predicate(".txt").Contains)

    End Sub

'delegate that defines the conditions of the elements to search for.
Public Class Predicate
    Private txt As String

    Public Sub New(txt As String)
        Me.txt = txt
    End Sub

    Public Function Contains(row As String) As Boolean
        Return row.Contains(txt)
    End Function

End Class