DeleteFile Method

Deletes a file by passing the request directly to the filesystem.

Syntax

int DeleteFile(const char* lpszFileName, int bCloseOpenHandles);
INT DeleteFile(LPCWSTR lpszFileName, BOOL bCloseOpenHandles);

Remarks

This method should be used instead of the Windows API's DeleteFile function to delete the file specified by FileName when some other process has it open exclusively, or when the application doesn't have sufficient security rights/permissions to access it in a "standard" way.

If CloseOpenHandles is true, this method closes and invalidates all opened handles to the file before deleting it.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

 
 
Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Direct 2020 C++ Edition - Version 20.0 [Build 7836]