🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12404

Re: Disk Drives object

#12404
From: Mark Tiede
Date: Fri, 08 Jan 1999 00:00
88 lines
3142 bytes
This is a multi-part message in MIME format.
--------------59D57BCC1BED37CBB19DDFA7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julian,

   GREAT!   Just what I needed.  I saw that IsDirectory function and tried to
figure out how it would be useful (and used), but didn't manage.  I'll give your
suggestion a try!

Thanks.

Julian Monypenny wrote:

> Mark,
>
> I use the following code to list Windows NT drives. Note, the list only
> includes hard drives, not floppy or CD drives. You could assume the A drive
> exists, but if you try to access it when it doesn't contain a disk you get a
> Windows dialog message. The default assignment of the root directory in
> ListDrives is designed to work with non-Windows systems.
>
>  public static final String separator = File.separator;
>
>  /**
>   * Lists the drives on the system.
>   * @return  an array of the drives on the system
>   */
>  public static final String[] listDrives() {
>   Vector list = new Vector();
>   for (char drive = 'C'; drive < 'Z'; drive++) {
>    if (isDirectory(String.valueOf(drive) + ":")) {
>     list.addElement(String.valueOf(drive) + ":");
>    }
>   }
>   if (list.isEmpty()) {
>    list.addElement(separator);
>   }
>   String drives[] = new String[list.size()];
>   list.copyInto(drives);
>   return drives;
>  }
>
>  /**
>   * Checks if a string contains the name of a directory.
>   * @param name  the string that contains the name
>   * @return  true if the name is a directory; false otherwise
>   */
>  public static final boolean isDirectory(String name) {
>   File file = new File(name + separator);
>   return (file.isDirectory() &&
>    file.exists() &&
>    !name.equals(""));
>  }
>
> Julian
>
> Mark Tiede wrote in message <36940D10.C3A4EFBD@ibm.net>...
> >All,
> >
> >   I just spent about 3 hours looking through docs and source trying to
> >find out how I could make an object like the filedialog component does.
> >I want to make a list box that has the list of disk drives in it.
> >
> >   Any ideas?
> >
> >   Thanks.
> >

--------------59D57BCC1BED37CBB19DDFA7
Content-Type: text/x-vcard; charset=us-ascii;
 name="tiede.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark Tiede
Content-Disposition: attachment;
 filename="tiede.vcf"

begin:vcard 
n:Tiede;Mark
x-mozilla-html:TRUE
org:MJW Corporation;Multimedia Division
adr:;;;;;;
version:2.1
email;internet:tiede@ibm.net
end:vcard

--------------59D57BCC1BED37CBB19DDFA7--
Technical Details
Message-ID: <36961773.74DF9632@ibm.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36940D10.C3A4EFBD@ibm.net> <773205$fm114@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c87bf8c8df7752dc
X-Google-Attributes: gid111d45,public
From: Mark Tiede <tiede@ibm.net>
Subject: Re: Disk Drives object
Date: 1999/01/08
Message-ID: <36961773.74DF9632@ibm.net>
X-Deja-AN: 430196020
References: <36940D10.C3A4EFBD@ibm.net> <773205$fm114@forums.borland.com>
X-Accept-Language: en
Content-Type: multipart/mixed; boundary="------------59D57BCC1BED37CBB19DDFA7"
Organization: MJW Corporation
Mime-Version: 1.0
Reply-To: tiede@ibm.net
Newsgroups: borland.public.jbuilder.java.swing