How can I detect that a shell item refers to a virtual folder, or to a file system inside a file?


Shell items have a bunch of attributes. For example, SFGAO_FOLDER means that the item is a folder, and it will show up in the navigation pane as a folder. Since it’s a folder, you can bind to it and enumerate children. But what if you need more information about what kind of folder it is?

The other attributes SFGAO_FILE­SYSTEM, SFGAO_FILE­SYS­ANCESTOR, and SFGAO_STREAM can help you distinguish the various scenarios.

The SFGAO_FILE­SYSTEM attribute means that the item exists in the file system, and the parsing name for a SFGAO_FILE­SYSTEM object can be used to access the corresponding entity in the file system.

The SFGAO_FILE­SYS­ANCESTOR attribute means that the item or one of its children might have the SFGAO_FILE­SYSTEM attribute. This attribute is used by the File Open and File Save dialogs, for example, to decide whether to filter out the item. If it’s possible to reach the file system via the item, then the File Open and File Save dialogs will include the item. You may not be able to save directly to the item (such as My Computer), but it will let you navigate through it on the way to something you can save to.

The SFGAO_STREAM attribute means that the item can produce bytes of data. If combined with the SFGAO_FILE­SYSTEM attribute, it means that the underlying storage for the item is a file. Even though the underlying storage is a file system file, it may be exposed in the shell namespace as a folder. For example, ZIP files are file system files, but they show up in the shell namespace as a folder, so that you can open them up and drag files into or out of them.

Let’s summarize this in a chart.

Virtual file with no data Dial-up networking connectoid
SFGAO_STREAM Virtual file with data File on an FTP site
SFGAO_FOLDER   Virtual folder Control Panel
SFGAO_FOLDER | SFGAO_STREAM Virtual folder with data ?
SFGAO_FILE­SYSTEM   File system file with no data Symbolic link
SFGAO_FILE­SYSTEM | SFGAO_STREAM File system file with data Traditional file system file
SFGAO_FILE­SYSTEM | SFGAO_FOLDER   File system directory Traditional file system directory
SFGAO_FILE­SYSTEM | SFGAO_FOLDER | SFGAO_STREAM Virtual directory inside a file system file ZIP file

I couldn’t think of an example of a virtual folder with data.


Comments are closed. Login to edit/delete your existing comments