this MIGHT be relevant ?

The file / folder is NOT guranteed to be deleted right after DeleteFile returns and succeeded.

However, the NT model for file deletion is that a file is deleted when the last open handle is closed.Ā¹ If DeleteĀ­File returns and the file still exists, then it means that somebody else still has an open handle to the file.

I think maybe you can trace the exact problem with ProcessMonitor.