jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes How to get permanant drives Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get permanant drives" Watch "How to get permanant drives" New topic

How to get permanant drives

Lila Fowler
Ranch Hand

Joined: Jul 31, 2009
Posts: 84
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:



Courage is not the absence of fear but rather the judgment that something is more important then fear. ~ Ambrose Redmond
Rob Spoor

Joined: Oct 27, 2005
Posts: 20194

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.

How To Ask Questions How To Answer Questions
Lila Fowler
Ranch Hand

Joined: Jul 31, 2009
Posts: 84
Thanks =) , gonna try the type. - see what it will do on linux/mac
I agree. Here's the link: http://aspose.com/file-tools
subject: How to get permanant drives
It's not a secret anymore!