In my Computer path is C:\Users\RS\Music How to get the C:\Users\RS as the initial path may vary for every different user on same computer.
Asked
Active
Viewed 1,030 times
1
-
3[What have you tried](http://whathaveyoutried.com)? – Keppil Oct 24 '12 at 12:05
-
3please explain what you want to do, along with with your effort – NoNaMe Oct 24 '12 at 12:06
-
1@BlueBullet No, the question is not nonsense, but it might be, that the answer is: *"There is no system property like `user.home`. But if you are referring to the windows 'Music' folder in the home dir, you can access that using `System.getProperty("user.home")`."*... In that case, why don't you post this answer instead of ranting at newer members that don't have the same knowledge level than you have? – brimborium Oct 24 '12 at 12:16
2 Answers
3
System.property has an entire set of interesting keys to draw information out of. One of them is "user.home", it should contain the information you need.

G-Man
- 1,321
- 8
- 15
-
1No it does not, it only returns the "C:\Documents and Settings\Username" part. "My Documents" and "My Music" are named as such only on English Windows, in does not work in localized versions – mavroprovato Oct 24 '12 at 12:10
-
1the question is: "How to get the C:\Users\RS as the initial path may vary for every different user on same computer." in that case my answer is valid. i agree it's not the full solution to the problem, but it's the answer to the question. – G-Man Oct 24 '12 at 12:13
1
If you want the location of the Music folder then you have to read the Windows registry in order to do this. Some ways to read the windows registry are mentioned here
As for the specific registry key you need, for Windows XP it is the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music
key. For Windows 7, I'll update my answer when I have access to a PC that has it installed.

Community
- 1
- 1

mavroprovato
- 8,023
- 5
- 37
- 52
-
This is Windows specific, I'm on Linux and I have a 'Music' folder in the XFCE interface. How do you do this in Linux? – jamie Apr 20 '17 at 19:55