954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

find a specific directory

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?

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

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?

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

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;
				System.out.println(startingPath.toString());
			}
	}
	return startingPath;
   }
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

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.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You