Discuss this help topic in CBFS Forum

OnCleanupFile event/delegate/callback


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

CallbackFileSystem     See also    


This event is fired when the OS needs to cleanup the file.


    property OnCleanupFile : TCbFsCleanupFileEvent;
    TCbFsCleanupFileEvent = procedure( Sender : TObject; FileInfo: TCbFsFileInfo; HandleInfo: TCbFsHandleInfo ) of object;

[C++ (Lib)]
    void (__stdcall *CbFsCleanupFileEvent)(void* Sender, CbFsFileInfo* FileInfo, CbFsHandleInfo* HandleInfo );

[C++ (VCL)]
    typedef void (__closure *TCbFsCleanupFileEvent)( System::TObject* Sender, TCbFsFileInfo* FileInfo, TCbFsHandleInfo* HandleInfo );

[C++ (.NET)]
    public __delegate void CbFsCleanupFileEvent( CallbackFileSystem^ Sender, CbFsFileInfo^ FileInfo, CbFsHandleInfo^ HandleInfo );

    public void CbFsCleanupFileEvent( CallbackFileSystem Sender, CbFsFileInfo FileInfo, CbFsHandleInfo HandleInfo );

    Sub CbFsCleanupFileEvent( ByVal Sender As CallbackFileSystem, ByVal FileInfo As CbFsFileInfo, ByVal HandleInfo As TCbFsHandleInfo )

    void ICbFsFileEvents.onCleanupFile( CallbackFileSystem sender, CbFsFileInfo fileInfo, CbFsFileInfo FileInfo, CbFsHandleInfo HandleInfo );


  • Sender - reference to the class that called the delegate/event handler
  • FileInfo - contains information about the opened file
  • HandleInfo - contains information about particular opened file or directory handle


This event is fired when the OS needs to close the previously created or opened handle to the file. This event is different from OnCloseFile in that OnCleanupFile happens immediately when the last handle is closed by the application, while OnCloseFile can be called much later when the OS itself decides that the file can be closed. Use FileInfo and HandleInfo to identify the file that needs to be closed.
Read more about contexts.

OnCleanupFile is optional event.

Error handling

See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to Callback File System. Throwing ECBFSError exception from this event handler will not cause the OS to abort the operation or display an error message to the user.

See also

OnCloseFile     OnCreateFile     OnOpenFile    

Discuss this help topic in CBFS Forum