Xceed .NET Libraries Documentation
DateTimeFilter

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

The DateTimeFilter class can be used to filter files and folder according to their dates. By default, if a specific type of date is not specified (last accessed, creation, etc.), the last write date is consulted.

Demonstration

Process all files that have a last write date between January 1st 1999 and January 1st 2001.

VB.NET Copy Code

Dim files As AbstractFile() = myFolder.GetFiles( True, _
                                      New DateTimeFilter( New System.DateTime( 1999, 01, 01 ), _
                                      New System.DateTime( 2001, 01, 01 ) ) )

C# Copy Code

AbstractFile[] files = myFolder.GetFiles( true,
                                    new DateTimeFilter( new System.DateTime( 1999, 01, 01 ),
                                    new System.DateTime( 2001, 01, 01 ) ) );

Process all files that have a last accessed date between January 1st 1999 and January 1st 2001.

VB.NET Copy Code

Dim files As AbstractFile() = myFolder.GetFiles( True, _
                                   New DateTimeFilter( New System.DateTime( 1999, 01, 01 ), _
                                   New System.DateTime( 2001, 01, 01 ), _
                                   DateTimeFilter. ApplicableDateTimes.LastAccess ) )

C# Copy Code

AbstractFile[] files = myFolder.GetFiles( true,
                                          new DateTimeFilter( new System.DateTime( 1999, 01, 01 ),
                                          new System.DateTime( 2001, 01, 01 ),
                                          DateTimeFilter. ApplicableDateTimes.LastAccess ) );

Things you should consider

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

  • Do you want to filter according to a specific type of date? Use the ApplicableDateTimes enumeration in the constructor of the DateTimeFilter class.