Failed to delete folder using SHFileOperation

I cannot delete a folder in Windows with the following code:

SHFILEOPSTRUCT shfo = {
    NULL,
    FO_DELETE,
    path,
    NULL,
    FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION,
    FALSE,
    NULL,
    NULL };

SHFileOperation(&shfo);

I need to use SHFileOperationinstead RemoveDirectorybecause I need to delete non-empty folders.

However, the function crashes, even if the value in pathpoints to an empty local folder with full control of the Everyone user, with double zero termination (on request, it does not have a system, hidden or normal attribute ...

Unfortunately, the function does not return an error code (returns zero if it was successful, or otherwise otherwise) and the call GetLastErrorreturns ERROR_SUCCESS...

Where is the mistake?

+5
source share
1 answer

solvable ...

path , wcscpy_s, ( ) 0xFD char...

+11

All Articles