Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the current user directory?

Using this:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 

I get this output:

"C:\\Documents and Settings\\[USER]\\Application Data" 

How can I get the root directory of all users? i.e.:

"C:\\Documents and Settings\\[USER]\\" 
like image 894
juan Avatar asked Jul 16 '09 21:07

juan


People also ask

How do I find the users directory in Linux?

To navigate to your home directory, use "cd" or "cd ~" To navigate up one directory level, use "cd .." To navigate to the previous directory (or back), use "cd -" To navigate through multiple levels of directory at once, specify the full directory path that you want to go to.

How do I find my home directory?

To find your Home folder, open Finder and use the keyboard shortcut Command-Shift-H. You can use the Go pull-down menu from the menu bar to go to the Home folder. (Oddly, the home folder is called Home in this menu.)

How do I find the home directory in Swift?

Swift – Home Directory for Current User To get home directory for current user in Swift, read homeDirectoryForCurrentUser property of shared file manager object for the process.


1 Answers

Try:

System.Environment.GetEnvironmentVariable("USERPROFILE"); 

Edit:

If the version of .NET you are using is 4 or above, you can use the Environment.SpecialFolder enumeration:

Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); 
like image 92
Thomas Avatar answered Sep 19 '22 10:09

Thomas