• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I found paths to "My Computer", "Desktop", ... folders for the current user?

 
Yehor Mikhaylov
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All.
I want to create more useful file open/save dialog that uses JfileChooser. I want to add links to �Desktop�, �My Computer�, �My Documents�, �My Pictures� and so on like on open dialog in WinXp.
How can I found paths to these folders for the current user?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could... but you'd have to make the file chooser pretty much from scratch (or look at the code for JFileChooser and change it...), and then it would only be specific to Windows XP!

For example, on my Windows 2000 box here at work, most of these files are kept in C:\Documents and Settings\<username>, but I know that these are kept somewhere completely different on my Windows 98 box at home. And my linux box has no idea what "My Documents" are?!?!

The System class provides a platform independent way to get the user's home directory (System.getProperty( "user.home" )), but I would leave it up to the user to go to "My Documents", "My Pictures", etc.
[ February 27, 2003: Message edited by: Nathan Pruett ]
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on winxp and win2k you'd be safe saying this:
String home = System.getProperty("user.home");
String myDocs = home + "/My Documents";
String desktop = home + "/Desktop";
as far as my computer, you're screwed.
I'll re-inforce that you are losing all cross-platform capability here. Write the damn thing in VB.
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't you just check to see if you're running on a windows system and then add them in if applicable?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic