Forum Discussion

saberman's avatar
saberman
Copper Contributor
Jan 01, 2024

Walking Directories Finds A Directory That Doesn't Exist

I have a VBA application that walks directories and captures the number of files in each and their total size.  I hit an unusual problem.  A directory contains a reference to a subdirectory that doesn’t exist.

The reference is:
C:\Program Files (x86)\Microsoft Office\root\vfs\Common AppData\Application Data\*.*
It comes from:
FindFirstFileW(sPathFileUTF32, fdW)
Where sPathFileUTF32 is:
C:\Program Files (x86)\Microsoft Office\root\vfs\Common AppData

Attempt to walk it:
FindFirstFileW(sPathFileUTF32, fdW)
Where sPathFileUTF32 is:
C:\Program Files (x86)\Microsoft Office\root\vfs\Common AppData\Application Data\*.*
Throws an error:
Error[3]: The system cannot find the path specified.

File Manager does not see that subdirectory:

 

Dir in a CMD window does not see that subdirectory:

 

Why does FindFirstFileW return a path to a directory that does not exist?

  • Because the modern file system is WAY more complicated than your grandfather's file system. It contains virtual elements, and some APIs may see more than others.
    • saberman's avatar
      saberman
      Copper Contributor
      I am using the same API to look at the parent directory as to look at the non-existent subdirectory.

      The question is why would there be an entry in a directory for a subdirectory that doesn't exist.?

Resources