-
April 10th, 2000, 09:07 AM
#1
JComboBox and System Drive INFo
Hi all,
I would like to add my system drives(exa:- C:,D:,E: and mapped network drives ) to a combobox.SO , which method i should use to add all these at runtime.see,my network drives may change dynamically.so i need to add all these drives at run time only.this question is just like the "Look in:" item available in windows start menu -> find -> files & folders tabpage 1.
Thanks & Regards
Panda
EXIMSoft
Bangalore
rp_panda@blr.reliancesystems.com
-
April 10th, 2000, 09:28 AM
#2
Re: JComboBox and System Drive INFo
Hi,
The following should give you the system drives.
File[] roots = FileSystemView.getFileSystemView().getRoots();
for (int i = 0; i < roots.length; i++)
{
comboBoxinstance.addItem(roots[i]);
}
Good Luck.
Kannan
-
August 5th, 2003, 09:56 AM
#3
Can we differenciate between network drive (Mapped drive) and local drive (Hard Disk Drive)? You provide code for listing of all drives, but how about identification of both ?
Anyone who has never made a mistake has never tried anything new.
-
April 23rd, 2007, 06:18 AM
#4
Re: JComboBox and System Drive INFo
try this
Code:
DriveInfo[] driveList = DriveInfo.GetDrives();
// Loop through the list of drives
foreach (DriveInfo drive in driveList)
{
// It's a HDD
if (drive.DriveType == DriveType.Fixed)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 3);
}
// It's a CD-ROM, DVD-ROM, CD-RW, DVD+-RW or any other similar drive
else if (drive.DriveType == DriveType.CDRom)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 0);
}
// It's a floppy drive
else if (drive.DriveType == DriveType.Removable)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 2);
}
// It's a network drive
else if (drive.DriveType == DriveType.Network)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 4);
}
// It's a RAM drive
else if (drive.DriveType == DriveType.Ram)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 6);
}
-
April 23rd, 2007, 07:26 AM
#5
Re: JComboBox and System Drive INFo
Originally Posted by 2MuchRiceMakesMeSick
try this
Code:
DriveInfo[] driveList = DriveInfo.GetDrives();
// Loop through the list of drives
foreach (DriveInfo drive in driveList)
{
// It's a HDD
if (drive.DriveType == DriveType.Fixed)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 3);
}
// It's a CD-ROM, DVD-ROM, CD-RW, DVD+-RW or any other similar drive
else if (drive.DriveType == DriveType.CDRom)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 0);
}
// It's a floppy drive
else if (drive.DriveType == DriveType.Removable)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 2);
}
// It's a network drive
else if (drive.DriveType == DriveType.Network)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 4);
}
// It's a RAM drive
else if (drive.DriveType == DriveType.Ram)
{
treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 6);
}
Not only was the question you answered 4 years old, the answer was not even in Java.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|