Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get permanant drives

 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi =)

I'm trying to get the permanent available drives on a pc. Its easy enough to get all the drives available but is there a way to only get the drive that are consistent? For example i want it to ignore all network, cd/dvd and floppy drives.

Any idea's how i could solve this?

Here is my current code:



I get the following result:

C:\ //Local Drive
D:\ //Compact Disc
E:\ //Local Drive
F:\ //Removable Hard-drive
G:\ //Network Drive
H:\ //Compact Disc
V:\ //Network Drive
X:\ //Network Drive
Y:\ //Network Drive

The result i need:

C:\
E:\

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without using JNI there is one class I know that may help you out: FileSystemView.
Unfortunately, except for floppy drives these "is" methods do not return anything useful; on my system, they all return the same values. The type may be of use but I doubt that it is a portable solution - on a different system the labels may be different, or the method may even return null.
 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks =) , gonna try the type. - see what it will do on linux/mac
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic