• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create directory in root of client machine?  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My applet creates a directory on the client's machine to store persistent user data. I'm using:

File dir = new File("applet_user_data");
dir.mkdir();

...but with Win XP, this creates the directory on the users desktop!

I would prefer to make the dir within the users root directory. Does anyone know what code will achieve this regardless of the client system?

Thanks,
James
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specify the full path of the directory. If you don't, File assumes you want the current working directory.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers, but how do I specify the root directory - e.g., on most PCs this will usually be "C:\" but on other systems it could be something else...
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
User's home directory is in property called user.home.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ther user.home property gives you the name of the users home directory. Applets can't normally access this for security reasons, but since your applet needs to be signed anyway in order to do file I/O, that shouldn't be an issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!