wood burning stoves 2.0*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get permanant drives" Watch "How to get permanant drives" New topic
Author

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:

C:\
E:\

Thanks


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

Joined: Oct 27, 2005
Posts: 19672
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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