0

How can I read all files from mtp disk? I think could be easy as it's, but...

When I access into the drive using explorer it shows me the path as: "This computer/my phone/Internal storage/Dcim" I advice I can get acces if I write the path directly in files explorer in the same way: "This computer/my phone/Internal storage/Dcim"

But when I try to list the files from this vb code:

 Dim stringpat As String = "This computer\my phone\Internal storage\Dcim"
    For Each foundFile As String In My.Computer.FileSystem.GetFiles(stringpat)
        ListBox1.Items.Add(foundFile)
    Next 

the program tries to do it, but returns: System.IO.DirectoryNotFoundException: 'cannot be found part of access path showing common path like: 'C:\Users\PC\Desktop\proyect\proyect\bin\Debug\This computer\My phone\Internal storage\Dcim\'

Obviously My.Computer.FileSystem.GetFiles adds the undesired part of the path...

How can I access into a path that is not a common path like "C:", just start as I show?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • "This Computer" and "My Phone" are virtual folders created by Windows Explorer. They don't actually exist outside Explorer. `GetFiles` is working as it should - you've passed a path that does not start with a drive letter or backslash, so it assumes that you're starting in your executable's folder and trying to go into subfolders starting from there. – Ken White Jan 16 '22 at 03:18
  • 1
    It's quite an old post, so hopefully the answers are still good: [Accessing an MTP/WPD device in Visual Basic .NET](https://stackoverflow.com/questions/26514869/accessing-an-mtp-wpd-device-in-visual-basic-net). – Andrew Morton Jan 16 '22 at 17:20
  • Not sure of the answer, but I'd test it by using an folderbrowserdialog to navigate to the folder and see what path it returns and see if that works instead of the stringpat string you are currently using. – Jon Roberts Jan 17 '22 at 14:51

0 Answers0