1

I am writing a Delphi VCL application and I need to iterate the files on my phone and SD card using FindFirst and FindNext etc.

The phone is attached using USB and I can see the device and file system using Windows Explorer.

I expected to simply put in the path to the SD Card and use FindFirst, FindNext, e.g.:

procedure MyProc;
var
  sr: TSearchRec;
begin
  if FindFirst('This PC\My Phone Name\SD card\DCIM\Camera\*.jpg', faAnyFile, sr) = 0 then
    repeat
      Showmessage(sr.name);
      //blah
      ...
    until FindNext(sr) <> 0;
  FindClose(sr);
end;

Nothing has worked so far with Path not found errors I'm using Delphi 11.1

1 Answer 1

1

The reason why you can't iterate through Android phone files as you would do with local files is the fact that when you connect your phone to the computer you don't really get direct access to phones file structure.

Instead all the files are being transferred from the phone to your computer using Media Transfer Protocol

Now the reason why you can see the files from your phone in windows explorer as if they would be stored on computer is because windows explorer has a built-in functionality to work with MTP protocol. But even then if you look closely you will notice that when viewing files directly from your phone some of the usual explorer options are missing, context menu is different and so on.

2
  • Thank you Freddie, I'll take a look at this
    – gorepj01
    Nov 21 at 12:37
  • Surely you mean SilverWarior? Nov 22 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.