How to access files/folders on a MTP device?

On MSWindows XP and Vista, MP3 players nowadays will not be visible
as device lettered partitions, but as 'devices' accessible through a path that begins at 'desktop'.

How do I find that path from JAVA?

;JOOP!
LVL 24
sciuriwareAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Try

File f = new File(System.getProperty("user.home"), "Desktop");
0
 
objectsCommented:
try:  File.listRoots()
0
 
sciuriwareAuthor Commented:
CEHJ: that gives me the desktop with only the desktop icons in it.
objects: that gives me all drive letters.

When an MTP device is connected a pop up shows named "Portable Device".
You can double click "Open device to view files using Windows Explorer"
Windows explorer then shows (in case of a Creative ZEN mp3 player):
"Storage Media" at the address "My Computer\My Zen".

A file manager like Total Commander shows in directory tree mode:

[ ] Desktop
- [ ] My Computer
.................
+ [ ] My Zen

How do I get those links?

;JOOP!
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
objectsCommented:
> objects: that gives me all drive letters.

I realise that, does it not associate it with a drive?
0
 
sciuriwareAuthor Commented:
No that's the main problem ever since XP.

;JOOP!
0
 
objectsConnect With a Mentor Commented:
XP didn't have that problem that I ever saw. devices/flash drives got mapped to drive
0
 
CEHJCommented:
>>CEHJ: that gives me the desktop with only the desktop icons in it.

That will give you the Desktop directory. If that's where the filesystem of the MP3 device is mounted then there shouldn't be a problem although it seems odd it's not being mounted as a file system root
0
 
sciuriwareAuthor Commented:
CEHJ, if you can lay your hands on a Creative ZEN, you will find out.
For the moment I can only exchange fiules via Windows Explorer.

;JOOP!
0
 
sciuriwareAuthor Commented:
objects, same message as to CEHJ.
I was surprised too.

Anyway, I can't even see 'My Computer' in my Desktop folder.

;JOOP!
0
 
sciuriwareAuthor Commented:
P.S.:

Anyway, I can't even see 'My Computer' in my Desktop folder in a JFileChooser{}.

;JOOP!
0
 
CEHJCommented:
'My Computer' is not a subdirectory, or a shortcut, but i'm not sure what it is
0
 
sciuriwareAuthor Commented:
That's the point.

;JOOP!
0
 
CEHJCommented:
Can you post the result of

dir "%USERPROFILE%\Desktop"

?
0
 
sciuriwareAuthor Commented:
>>>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>dir "%USERPROFILE%\Desktop"
 Volume in drive C is NutkinSys
 Volume Serial Number is EC0F-456D

 Directory of C:\Documents and Settings\joop\Desktop

04-10-07  17:16    <DIR>          .
04-10-07  17:16    <DIR>          ..
04-04-07  15:01             2 855 Block Out.pif
30-11-05  12:39               564 MAP Kaibab.lnk
02-06-07  17:39               564 MAP Ratufa.lnk
30-11-05  12:40               568 UNMAP Kaibab.lnk
02-06-07  17:40               568 UNMAP Ratufa.lnk
               5 File(s)          5 119 bytes
               2 Dir(s)   2 265 378 816 bytes free

C:\>
<<<

;JOOP!
0
 
CEHJCommented:
That's a sparse but intriguing desktop ;-) Haven't come across that listing before. Is it listing Out.pif as a Unix-like block device? Could that be the player?
0
 
sciuriwareAuthor Commented:
Block Out is an MSDOS game.
I wrote my own Program Manager in Java, so my Desktop is a bit empty.
Should I try to put My Computer in there? How?
;JOOP!
0
 
CEHJCommented:
>>Block Out is an MSDOS game.

Sorry - misread that then. What about MAP and UNMAP?
0
 
sciuriwareAuthor Commented:
Shortcuts to .bat scripts

;JOOP!
0
 
CEHJCommented:
All quite strange. So you see an icon representing the player on the desktop
0
 
sciuriwareAuthor Commented:
No. in the system tray only.

;JOOP!
0
 
sciuriwareAuthor Commented:
If even objects and CEHJ don't know of a solution, I conclude that such access
must be made through JNI code.

In the mean time I discovered that the latest release of Total Commander (file manager) 7.02
has a command to put my MP3 playerin a pane, even not having a drive letter.
The command is: Command->Open Desktop Directory.

In order to make this solution visible to searchers I will give you some points.
Thanks.
;JOOP!
0
 
CEHJCommented:
Has this got a USB interface?
0
 
CEHJCommented:
Assuming yes, you might try to ignore the FS and go straight to the device using something like:

http://jusb.sourceforge.net
0
 
sciuriwareAuthor Commented:
Yes it has.
I'll dig into this.

;JOOP!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.