473,394 Members | 2,160 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,394 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 19376
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.