c++winapicommtpwpd

How to get the list of all the files(objects) in a folder exposed by an MTP device using Windows Portable Devices C++ API?


It is possible to enumerate all the files in an MTP device's file system and then get object id's for each file/folder in the system.

My questions are:

  1. Is there a method to find if an object is a file or a folder?
  2. Once the folder is found how to get the list of all files(Objects) in it ?

I have checked the Programmer's reference page in msdn website but did not find anything relevant. Am I missing something ?

Thanks!


Solution

    1. Using IPortableDeviceValues (which you get from the IPortableDeviceProperties::GetValues() method), query for WPD_OBJECT_CONTENT_TYPE. It will return WPD_CONTENT_TYPE_FOLDER if the object is a folder.

    2. Using the IPortableDeviceContent::EnumObjects() method, you can enumerate the content of any folder objects.