Xceed .NET Libraries Documentation
Welcome to Xceed Data Manipulation Compoents for .NET and .NET Standard / Basic Concepts / Filters / OrFilter

In This Topic
    OrFilter
    In This Topic

    The OrFilter class serves the same purpose as a logical-or operator. It states the items must match at least one of the filters it regroups in order to be processed.

    Demonstrations

    This example processes all the files that have the TXT or the EXE extension.

    VB.NET Copy Code

    Dim files As AbstractFile() = myFolder.GetFiles( New OrFilter( New NameFilter( "*.txt" ), _
                                                     New NameFilter( "*.exe" ) ) )

    C# Copy Code

    AbstractFile[] files = myFolder.GetFiles( new OrFilter( new NameFilter( "*.txt" ),
                                              new NameFilter( "*.exe" ) ) );

    Since using a pipe (|) in the constructor of a NameFilter class accomplishes the same thing as regrouping multiple NameFilter classes within an OrFilter class, the following code would be simpler.

    VB.NET Copy Code
    Dim files As AbstractFile() = myFolder.GetFiles( "*.txt|*.exe" )
    C# Copy Code
    AbstractFile[] files = myFolder.GetFiles( "*.txt|*.exe" );

    This example processes all the files that have the TXT extension or are greater than 10k in size. Again, we omit the creation of the NameFilter class around the name mask since it is already being created underneath.

    VB.NET Copy Code

    Dim filter = new SizeFilter()

    filter.MinSize = 10240
    Dim files As AbstractFile() = myFolder.GetFiles( New OrFilter( "*.txt", filter ) )

    C# Copy Code

    SizeFilter filter = new SizeFilter();

    filter.MinSize = 10240;
    AbstractFile[] files = myFolder.GetFiles( new OrFilter( "*.txt", filter ) );