0

How do you determine what the main hard drive is?

This is what I have:

filename="savefile2.txt";

and this is pseudocode for what I want:

filename="MainDrive:/JavaProject/savefile2.txt";

My problem with it is, what if C: isn't the name of a person's hard drive? F:\ for instance. And also, if the folder name specified does not exist in their drive, is it automatically created?

EDIT:
I figured out I need to make the directory first

String directory="C:\\JavaProject\\";
	boolean success = new File(directory).mkdir();

Now how do I make the C:\ a general hard drive?

EDIT:
NEVERMIND I GOT IT lol.

String directory="\\Program Files\\JavaProject\\";
	boolean success = new File(directory).mkdir();

Edited by Slyvr: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by java_programmer
This question has already been answered. 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.