I am using FindFirstFile and FindNextFile to show a list of files in a given folder in my application.
On occasion, I'm seeing cases where my application deletes a folder using SHFileOperation, but the folder can still be found by FindFirstFile. I've seen this problem reported previously on StackOverflow here: File deleted with remove function still shows up in FindFirstFile/FindNextFile. However, in my case I'm not using remove and the folder remains visible even after clearing the recycle bin. In addition, the folder is NOT visible in Windows file explorer. This makes me wonder what the file explorer is filtering on to ignore the file.
I tried looking at file attributes but only found that the deleted folder had FILE_ATTRIBUTE_DIRECTORY and FILE_ATTRIBUTE_VIRTUAL set. The FILE_ATTRIBUTE_VIRTUAL attribute is a bit mysterious (MSDN says it's reserved for system uses), so I tried ignoring folders that had that attribute set. However, it turns out that there are legitimate existing/active folders that have this attribute set, so I'm unable to use it as a filter.
Why is this folder showing up? How can I ignore it and not ignore existing (non-deleted) folders?