I know how to find a directory if I know the full path name of the directory I'm searching for..But, let's say I only know the directory name, and not the full path name..How can I find that directory on a users system? Is there some recursive function or looping structure to achieve this?

13 Years
Discussion Span
Last Post by jwenting

Ok, I found out how to search. Now the only thing I need to know is, how do you find out what the users root directory is?


This is what I'm trying right now, but it's not working..

public File PathStart()
	for (char dirs='A'; dirs >= 'Z'; dirs++)
		File path = new File(dirs + "://");
			if (path.isDirectory())
				startingPath = path;
	return startingPath;

For one that will only work on Windows machines, not anywhere else.
Try to write Java code to be platform independent...

Look at the class System for a method getProperties().
This will retrieve the system properties which, among other things, contains a reference to the current working directory as well as to the current user's home directory.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.