Hi @Achim Schneider ,
Thanks for the detailed post.
Your result is consistent with documented NTFS behavior. I'd still keep that separate from confirmation that your exact application API sequence is officially supported.
MS-FSA §2.1.5.7 explicitly covers directory objects, requires file-system metadata to reach stable storage, and requires flushing the underlying physical storage. It states:
The operation ensures that the directory structure is persisted to stable storage.
Product note <80> identifies NTFS as the file system that implements this directory-persistence behavior. So if your call performs the specified operation on the actual parent directory after the deletion has completed, the expected semantics include persistence of that removal, under your storage assumptions. Because the behavior is specific to NTFS, a successful flush is only meaningful there. Your application should confirm the volume is NTFS before relying on it.
The unresolved point is the documented link between that operation and your particular handle-opening sequence. MS-FSA specifies an abstract object-store model that supports CIFS/SMB. It isn't a Win32 or Native API contract for local applications. The FlushFileBuffers reference requires GENERIC_WRITE, but it doesn't address directory handles or describe persistence of a preceding directory-entry removal.
The access-right requirements also conflict. The NtCreateFile reference says not to specify FILE_READ_DATA, FILE_WRITE_DATA, FILE_APPEND_DATA, or FILE_EXECUTE when opening a directory. Meanwhile, GENERIC_WRITE, which FlushFileBuffers requires, maps to FILE_WRITE_DATA and FILE_APPEND_DATA among other rights (see File Security and Access Rights). The documentation doesn't reconcile these two requirements for directory handles. I wouldn't conclude from this that writable directory handles are unsupported, but it's part of what needs confirmation.
For the reopening step, ReOpenFile is a documented alternative. It can reopen directory handles with different access rights using FILE_FLAG_BACKUP_SEMANTICS, subject to access and sharing checks. It has two limits here:
- The original handle must come from
CreateFile, so your current pinned handle may not qualify. - Reopening with
GENERIC_WRITEruns into the same directory access-right conflict described above.
So ReOpenFile avoids depending on the empty-name native reopen, but it doesn't settle the access-right or durability questions.
Windows 11 is on MS-FSA's applicability list, and note <80> has no version-specific cutoff. That still doesn't amount to a support matrix for this exact sequence. Likewise, with AppData virtualization, you need to identify the actual backing parent directory and the application's trust and virtualization configuration. Matching directory identities alone doesn't establish a durability contract for the merged namespace.
For alternatives:
- Volume flushing is documented, but it requires administrative privileges.
- Transactional NTFS (TxF) offers transactional deletion through DeleteFileTransactedW. That page doesn't state a power-loss guarantee, so any durability expectation would have to rest on the broader TxF documentation. The function works only on local files and isn't supported on ReFS or over SMB 3.0. Microsoft also discourages new TxF dependencies because TxF may not be available in future Windows versions. It isn't a documented equivalent for this deployment.
If you found my support helpful, I’d really appreciate it if you could follow this guide so others with similar issue can benefit as well.
Thank you.