Using windows/shell api (atl be ok), given a folder's PIDL, what's the fastest way to check if a file exists in that folder?
Not sure if this is the fastest way, but it is fairly straight-forward:
Convert the PIDL
to an IShellFolder
(if you don't already have one) using SHGetDesktopFolder()
and IShellFolder::BindToObject()
, or just SHBindToObject()
, or other related function. And then call the folder's IShellFolder::ParseDisplayName()
(and, if needed, IShellFolder::GetAttributesOf()
) for the child filename. If an error occurs, the file does not exist.
Alternatively, convert the PIDL
to an IShellItem
(if you don't already have one) using SHCreateItemFromIDList()
, and then use SHCreateItemFromRelativeName()
(and, if needed, IShellItem::GetAttributes(SFGAO_VALIDATE)
) for the child filename. Again, if an error occurs (or the attributes don't validate), the file does not exist.