Link to home
Start Free TrialLog in
Avatar of sciuriware
sciuriware

asked on

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!
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try:  File.listRoots()
Avatar of sciuriware
sciuriware

ASKER

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!
> objects: that gives me all drive letters.

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

;JOOP!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>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
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!
objects, same message as to CEHJ.
I was surprised too.

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

;JOOP!
P.S.:

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

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

;JOOP!
Can you post the result of

dir "%USERPROFILE%\Desktop"

?
>>>
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!
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?
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!
>>Block Out is an MSDOS game.

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

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

;JOOP!
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!
Has this got a USB interface?
Assuming yes, you might try to ignore the FS and go straight to the device using something like:

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

;JOOP!