473,226 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Getting File System Root Directory

I've seen install programs that search a hard drive for previous instances
of a program, or to find installs of other needed programs.

I need to search a hard drive for any installations of OpenOffice. I know
in *nix I can start by using "/" as the file name and doing a recursive
listing of the file system from there. (Yes -- I know about permissions to
read directories -- that's another issue I've already solved.)

How do I find the root level for Windows boxen? For example, if a Windows
box has C:, D:, and E: drives, how do I get a list of all the drives so I
can scan them -- AND how can I tell which ones have media in them so I
don't scan floppies or CD-ROMs that are empty?

Thanks!

Hal
Jul 17 '05 #1
3 19364
For finding the drives on windows box,
do you need to be machine independent or
are you willing to use JNI?

There is a windows function that returns a long
with one bit for each of the possible 26 drives A thru Z.

I have a JNI program that uses it to find out how
much disk space there is on my C: and D: drives that
I can send you as an example.

By convention, A and B are floppy, beyond that I don't
know how to tell if a drive is a CD-ROM, tape, or
mapped network drive. There may be more MS library
functions that do that though.

Phil...

"Hal Vaughan" <ha*@thresholddigital.com> wrote in message
news:asjeb.642760$o%2.301439@sccrnsc02...
I've seen install programs that search a hard drive for previous instances
of a program, or to find installs of other needed programs.

I need to search a hard drive for any installations of OpenOffice. I know
in *nix I can start by using "/" as the file name and doing a recursive
listing of the file system from there. (Yes -- I know about permissions to read directories -- that's another issue I've already solved.)

How do I find the root level for Windows boxen? For example, if a Windows
box has C:, D:, and E: drives, how do I get a list of all the drives so I
can scan them -- AND how can I tell which ones have media in them so I
don't scan floppies or CD-ROMs that are empty?

Thanks!

Hal

Jul 17 '05 #2
Phil... wrote:
For finding the drives on windows box,
do you need to be machine independent or
are you willing to use JNI?
I'm trying to keep it platform independent. At this point I'm making sure
it works on Linux and Windows. I want to test Mac in a month or two. (I
hear about all I need to worry about is a different file separator
character, which shouldn't be a problem since I get that from either the
System properties or the File class.)

Although I am adding in code to handle a few things that might differ from
system to system.
There is a windows function that returns a long
with one bit for each of the possible 26 drives A thru Z.

I have a JNI program that uses it to find out how
much disk space there is on my C: and D: drives that
I can send you as an example.

By convention, A and B are floppy, beyond that I don't
know how to tell if a drive is a CD-ROM, tape, or
mapped network drive. There may be more MS library
functions that do that though.

Phil...
I found one way to do it -- if I detect I'm on Windows, I can cycle through
the entire list of strings ("A:", "B:", etc) and check if each exists.
It's a small detail, but I was hoping there was an "elegant" cross-platform
way to specify the root directory (like "/" in *nix). I even looked
through Swing to see if there was anything in JFileChooser that would let
me make a filechooser and get the info, without ever showing the chooser.

Thanks, again, Phil, for the info!

Hal
"Hal Vaughan" <ha*@thresholddigital.com> wrote in message
news:asjeb.642760$o%2.301439@sccrnsc02...
I've seen install programs that search a hard drive for previous
instances of a program, or to find installs of other needed programs.

I need to search a hard drive for any installations of OpenOffice. I
know in *nix I can start by using "/" as the file name and doing a
recursive
listing of the file system from there. (Yes -- I know about permissions

to
read directories -- that's another issue I've already solved.)

How do I find the root level for Windows boxen? For example, if a
Windows box has C:, D:, and E: drives, how do I get a list of all the
drives so I can scan them -- AND how can I tell which ones have media in
them so I don't scan floppies or CD-ROMs that are empty?

Thanks!

Hal


Jul 17 '05 #3
File[] roots = File.listRoots();
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mr. B | last post by:
I'm writing an app where I'm trying to look for and List all specific file 'types' found. So I point to a specific start top level Folder... and I want to drill down through ALL sub folders to...
0
by: Bill Burwell | last post by:
I am converting a VB6 WebClass application to VB.Net. Used the VB upgrade tool to do the conversion - and it left me a lot of little code things to do. Did those code things and got my app to...
13
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
1
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
5
by: Justin Fancy | last post by:
Hi Everyone, I am developing a file aging program that will eventually report on every folder that is in the root directory. I have a list of requested years, and counters set up to count every...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
15
denny1824
by: denny1824 | last post by:
I have a working website. I copied all the files to a new folder in inetpub/wwwroot and then set that folder as a Virtual Directory in IIS. I try going to that site from the new folder and i am...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.