Xceed .NET Libraries Documentation
AttributeFilter

Welcome to Xceed .NET, .NET Standard and Xamarin Libraries! > Basic Concepts > Filters > AttributeFilter

The AttributeFilter class can be used to filter files and folders according to their attributes. The attributes are specified by using the FileAttributes enumeration.

Demonstration

Process all files that have the read-only attribute.

VB.NET Copy Code
Dim files As AbstractFile() = myFolder.GetFiles( True, _
                                           New AttributeFilter( System.IO.FileAttributes.ReadOnly ) )
C# Copy Code
AbstractFile[] files = myFolder.GetFiles( true, 
                                    new AttributeFilter( System.IO.FileAttributes.ReadOnly ) );

Process all files that have both the read-only and the hidden attribute.

VB.NET Copy Code

Dim files As AbstractFile() = myFolder.GetFiles( True, _
                                     New AttributeFilter( System.IO.FileAttributes.ReadOnly ), _
                                     New AttributeFilter( System.IO.FileAttributes.Hidden ) )

C# Copy Code

AbstractFile[] files = myFolder.GetFiles( true,
                              new AttributeFilter( System.IO.FileAttributes.ReadOnly ), 
                              new AttributeFilter( System.IO.FileAttributes.Hidden ) );

Process all files that have either the read-only or hidden attribute.

VB.NET Copy Code
Dim files As AbstractFile() = myFolder.GetFiles( True, _ 
             New AttributeFilter( System.IO.FileAttributes.ReadOnly|System.IO.FileAttributes.Hidden ) )
C# Copy Code
AbstractFile[] files = myFolder.GetFiles( true,
            new AttributeFilter( System.IO.FileAttributes.ReadOnly|System.IO.FileAttributes.Hidden ) );

The pipe (|) used in the constructor of the AttributeFilter class serves the same purpose as an OrFilter class.

Things you should consider

  • Do you only want to target specific types of folder items? Use the FilterScope enumeration in the constructor of the AttributeFilter class.