OnCanFileBeDeletedC event/delegate/callback

Filter:

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

CBFSFilter     See also    

Overview

This callback is called when the OS needs to query possibility to delete the file or directory.

Declaration

[Pascal]
    property OnCanFileBeDeletedC : TCBFSFltCanFileBeDeletedEventC;
    TCBFSFltCanFileBeDeletedEventC = procedure(Sender : TObject; FileName: TCBString; var DeleteFile: Boolean; var FileContext: pointer; var HandleContext : pointer; var ProcessRequest: boolean) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CBFSFltCanFileBeDeletedEventC)(CBFSFilter* Sender, LPWSTR FileName, LPBOOL DeleteFile, PVOID* FileContext, PVOID* HandleContext, LPBOOL ProcessRequest);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCBFSFltCanFileBeDeletedEventC)(System::TObject* Sender, TCBString FileName, bool &DeleteFile, void * &FileContext, void * &HandleContext, bool &ProcessRequest);
    #ifdef UNICODE
    typedef UnicodeString TCBString;
    #else
    typedef WideString TCBString;
    #endif

[C++ (.NET)]
    public delegate void CBFSFltCanFileBeDeletedEventC(CBFSFilter^ Sender, String^ FileName, bool% DeleteFile, IntPtr% FileContext, IntPtr% HandleContext, bool% ProcessRequest);

[C#]
    delegate void CBFSFltCanFileBeDeletedEventC(CBFSFilter Sender, string FileName, ref bool DeleteFile, ref IntPtr FileContext, ref IntPtr HandleContext, ref bool ProcessRequest);

[VB.NET]
    Delegate Sub CBFSFltCanFileBeDeletedEventC(ByVal Sender As CBFSFilter, ByVal FileName As String, ByRef DeleteFile As Boolean, ByRef FileContext As IntPtr, ByRef HandleContext As IntPtr, ByRef ProcessRequest As Boolean)

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileName - name of the file
  • DeleteFile - set this parameter to allow or prevent deletion of the file
  • FileContext - the placeholder for the application-defined data, common to all concurrent file operations on the file
  • HandleContext - the placeholder for the application-defined data, local to each opened file handle
  • ProcessRequest - specifies, whether the request must be passed further to the underlying filters and the file system

Description

This callback is called when the OS needs to check if the file or directory can be deleted. When the callback/event handler is called, DeleteFile contains the value of the flag set by the OS or the application to indicate whether the file should be deleted. The OS or the application can set and clear the deletion flag in any order.

If you set DeleteFile to false, doing this will prevent deletion but will not report that deletion was not performed to the OS, and the caller will think that the file has been deleted. If you want to return an error, thrown ECBFSFltError instead with the appropriate error code (eg. ACCESS_DENIED).

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

OnPostCanFileBeDeletedC     OnCanFileBeDeletedN