OnEnumerateDirectoryC event/delegate/callback


Pascal    C++ (Lib)    C++ (VCL)    C++ (.NET)    C#    VB.NET   

CBFSFilter     See also    


This callback is called during directory enumeration.


    property OnEnumerateDirectoryC : TCBFSFltEnumerateDirectoryEventC;
    TCBFSFltEnumerateDirectoryEventC = procedure(Sender : TObject; DirectoryName: TCBString; FileName: TCBString; var CreationTime: TDateTime; var LastAccessTime: TDateTime; var LastWriteTime: TDateTime; var EndOfFile: Int64; var AllocationSize: Int64; var FileId: Int64; var FileAttributes: LongWord; var FileContext: pointer; var HandleContext : pointer; var EnumerationContext: pointer; var ProcessRequest: boolean) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CBFSFltEnumerateDirectoryEventC)(CBFSFilter* Sender, LPCWSTR DirectoryName, LPCWSTR FileName, FILETIME * CreationTime, FILETIME * LastAccessTime, FILETIME * LastWriteTime, __int64 * EndOfFile, __int64 * AllocationSize, __int64 * FileId, DWORD * FileAttributes, PVOID* FileContext, PVOID* HandleContext, PVOID* EnumerationContext, LPBOOL ProcessRequest);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCBFSFltEnumerateDirectoryEventC)(System::TObject* Sender, TCBString DirectoryName, TCBString FileName, TDateTime & CreationTime, TDateTime & LastAccessTime, TDateTime & LastWriteTime, __int64 & EndOfFile, __int64 & AllocationSize, __int64 & FileId, unsigned long & FileAttributes, void * &FileContext, void * &HandleContext, void * &EnumerationContext, bool &ProcessRequest);

[C++ (.NET)]
    public delegate void CBFSFltEnumerateDirectoryEventC(CBFSFilter^ Sender, String^ DirectoryName, String^ FileName, DateTime% CreationTime, DateTime% LastAccessTime, DateTime% LastWriteTime, Int64% EndOfFile, Int64% AllocationSize, Int64% FileId, UInt32% FileAttributes, IntPtr% FileContext, IntPtr% HandleContext, IntPtr% EnumerationContext, bool% ProcessRequest);

    delegate void CBFSFltEnumerateDirectoryEventC(CBFSFilter Sender, string DirectoryName, string FileName, ref DateTime CreationTime, ref DateTime LastAccessTime, ref DateTime LastWriteTime, ref Int64 EndOfFile, ref Int64 AllocationSize, ref Int64 FileId, ref UInt32 FileAttributes, ref IntPtr FileContext, ref IntPtr HandleContext, ref IntPtr EnumerationContext, ref bool ProcessRequest);

    Delegate Sub CBFSFltEnumerateDirectoryEventC(ByVal Sender As CBFSFilter, ByVal DirectoryName As String, ByVal FileName As String, ByRef CreationTime As DateTime, ByRef LastAccessTime As DateTime, ByRef LastWriteTime As DateTime, ByRef EndOfFile As Int64, ByRef AllocationSize As Int64, ByRef FileId As Int64, ByRef FileAttributes As UInt32, ByRef FileContext As IntPtr, ByRef HandleContext As IntPtr, ByRef EnumerationContext As IntPtr, ByRef ProcessRequest As Boolean)


  • Sender - reference to the class that called the delegate/event handler
  • DirectoryName - contains the name of the directory, in which enumeration is done
  • FileName - the name of the found file or directory
  • CreationTime - the time of the object creation
  • LastAccessTime - the time of last access to the object
  • LastWriteTime - the time of last modification of the object
  • EndOfFile - the size of the file
  • AllocationSize - the size of the space, allocated for the file
  • FileId - Currently unused.
  • FileAttributes - the attributes of the file or directory
  • FileContext - the placeholder for the application-defined data, common to all concurrent directory operations on the directory
  • HandleContext - the placeholder for the application-defined data, local to each opened directory handle
  • FileContext - the placeholder for the application-defined data specific to directory being opened
  • EnumerationContext - the placeholder for the application-defined data specific to particular enumeration procedure
  • ProcessRequest - specifies, whether the request results (contained in other parameters) must be passed to the OS


This callback is called when the OS enumerates files and subdirectories in the given directory. The callback is called after it has been processed by the file system. The user can hide the reported file form the OS by setting ProcessRequest parameter to false.

The application can use FileContext and HandleContext to store the reference to some information that identifies the directory which is opened in particular for enumeration (such as file/directory handle or database record ID or reference to the stream class etc). The values, set in the event handler, are later passed to operations related to this directory.
EnumerationContext is used to store application-defined data during particular enumeration. There can be several enumerations performed on single opened directory so FileContext, HandleContext and EnumerationConext are separated.
Read more about contexts.

Error handling

See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to CBFSFilter.

See also