0

I have the following problem:

I am using the Shell32 library to be able to access files even on external devices such as my android phone. Getting a local folder and the Phone itself works, but not the folder on the phone. My current code to get a folder (found the solution here):

Shell shell = new Shell();
Folder folder = shell.BrowseForFolder((int)Hwnd, "Choose Folder", 0, 0);
if (folder != null) {
   FolderItem fi = (folder as Folder3).Self;
   string path = fi.Path;
   //...
}

And later I am trying to get the Folder again by using:

Folder folder = shell.NameSpace(path);

which works fine for all local files and the phone itself, but not for the directories on the phone. The path for a local directory looks like a normal path: "D:\\Bilder\\Bretagne 2016",

the one for the phone:

"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\\\\?\\usb#vid_04e8&pid_6860&ms_comp_mtp&samsung_android#6&2a1f2d33&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}",

which is some identifier, but works and then for a specific directory on my phone:

"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\\\\?\\usb#vid_04e8&pid_6860&ms_comp_mtp&samsung_android#6&2a1f2d33&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\\SID-{10001,SECZ9519043CHOHB,114301988864}\\{E398106A-CD20-9A9C-490B-5079C2D70B84}"

with this path I just get a null object when calling shell.NameSpace(path);

Has anyone an idea what I am doing wrong? Have absolutely no idea how to fix this.

Thanks in advance,

Finn

Fingeg
  • 61
  • 5
  • https://stackoverflow.com/questions/18512737/how-to-manage-files-on-an-mtp-portable-device – Hans Passant Nov 09 '21 at 22:14
  • looks like a valid solution for external devices. Gonna use it as a workaround, but it requires me to handle phones and local files separately. Still wondering why my approach does not work – Fingeg Nov 10 '21 at 18:37

1 Answers1

0

So, found an interesting workaround.

To get a folder on my phone, I can just join the id/path I get from selecting the phone in the BrowseForFolder dialog and the human readable path like this: ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\\\\?\\usb#vid_04e8&pid_6860&ms_comp_mtp&samsung_android#6&2a1f2d33&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\\Phone\DCIM\Camera and everything works fine.

Not really an idea why the path you get from Folder.path does not work, but this does. As long as there is no other solution this works at least.

Fingeg
  • 61
  • 5