Show / Hide Table of Contents

Class AgedFileInfoCollection

This class hides its data in a List of AgedFileInfo objects, which its constructors assemble from permutations of the array of FileInfo objects returned by the GetFiles method on the DirectoryInfo instance that is fed into it.

Inheritance
System.Object
AgedFileInfoCollection
Namespace: WizardWrx.Core
Assembly: WizardWrx.Core.dll
Syntax
public class AgedFileInfoCollection : object
Remarks

This class and AgedFileInfo are designed to be used together to achieve the goal of processing a list of the files that match a file specification from newest to oldest.

Each AgedFileInfo is a FileInfo object, wrapped in a small class that augments it with a custom IComparable interface implementation that allows the list to be sorted by LastWriteTimeUTC. Using LastWriteTimeUTC guarantees that the files are always sorted correctly, even when the set includes one or more files that were created during the transition hour that occurs twice annually, on the days when the transitions to and from Daylight Saving Time occur. LastWriteTimeUTC time stamps created during this hour are not guaranteed to sort correctly, especially during the "fall back" transition that occurs in Autumn, when the local time is set back by 1 hour, so that there are two hours during which the same local hour is reported.

Constructors

| Improve this Doc View Source

AgedFileInfoCollection(DirectoryInfo)

The simplest of the three public constructors takes a reference to a DirectoryInfo collection, which is loaded in its entirety.

Declaration
public AgedFileInfoCollection(DirectoryInfo pdirInfoCollection)
Parameters
Type Name Description
DirectoryInfo pdirInfoCollection

The DirectoryInfo collection from which to populate the instance

| Improve this Doc View Source

AgedFileInfoCollection(DirectoryInfo, String)

A slightly more advanced constructor restricts the files to those that match a standard file name mask.

Declaration
public AgedFileInfoCollection(DirectoryInfo pdirInfoCollection, string pstrFileSpec)
Parameters
Type Name Description
DirectoryInfo pdirInfoCollection

The DirectoryInfo collection from which to populate the instance

System.String pstrFileSpec

The string to employ as a search mask

| Improve this Doc View Source

AgedFileInfoCollection(DirectoryInfo, String, SearchOption)

The most advanced constructor includes the restriction to a file name mask, to which it adds a SearchOption enumeration member that specifies whether to apply the mask to subdirectories.

Declaration
public AgedFileInfoCollection(DirectoryInfo pdirInfoCollection, string pstrFileSpec, SearchOption penmSearchOption)
Parameters
Type Name Description
DirectoryInfo pdirInfoCollection

The DirectoryInfo collection from which to populate the instance

System.String pstrFileSpec

The string to employ as a search mask

SearchOption penmSearchOption

The SearchOption that determines whether subdirectories are searched or ignored

Properties

| Improve this Doc View Source

Count

Read the count off the private list.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

GetFirstFileInfo()

Unless the list is empty, return the newest file in it, which is the first file in the list, since it is reverse sorted by LastWriteTime.

Declaration
public FileInfo GetFirstFileInfo()
Returns
Type Description
FileInfo

The returned FileInfo object represents the newest file in the list, which occupies its first slot, since the list is sorted in reverse order by LastWriteTimeUTC.

| Improve this Doc View Source

GetLastFileInfo()

Unless the list is empty, return the oldest file in it, which is the last file in the list, since it is reverse sorted by LastWriteTime.

Declaration
public FileInfo GetLastFileInfo()
Returns
Type Description
FileInfo

The returned FileInfo object represents the oldest file in the list, which occupies its last slot, since the list is sorted in reverse order by LastWriteTimeUTC.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX