Search code examples
delphidelphi-xe6

List folders with the same name in the same directory - Delphi


Good day ... I am listing the folder within a directory with Delphi ...

if FindFirst (directory + '*. *', faAnyFile, searchrec) = 0 then

But the big problem is that Delphi XE6, created two folders with the same name in Documents:

Embarcadero (Folder 1) (There are two folders with the same name in the same location)
Embarcadero (Folder 2)

When I list with FindFirst, it only shows a folder in the case only the first folder .. But each of these folder have different files ...

How do I list the two folders that have the same name and are in the same place ... ???


Solution

  • There are not two objects with the same name in the same directory. That is not possible at the file system level. What you are seeing is the shell presenting objects from multiple directories inside the same virtual container.

    The Documents shell object is in fact a library, a shell feature introduced in Windows 7. By default the Documents library contains the contents of your My Documents folder (C:\Users\your user name\My Documents) and the contents of the Public Documents folder (C:\Users\Public\Public Documents). And Embarcadero place a directory of that name in each of those two file system locations.

    If you wish to replicate what you see in the shell you need to use the shell API to enumerate the objects in this library.