Questions tagged [special-folders]

"Special folders" refers to directories in the Windows operating system that provide extended functionality in the user interface. Prominent examples are the "Desktop", "Start Menu", the "My Documents" and the "Fonts" folders.

The physical location and the number of special folders depend on the Windows version and system language.

Windows transparently manages the correlation between physical location on the disk and representation in the shell namespace, so these folders are best retrieved through the Windows API, as opposed to using fixed paths.

200 questions
129
votes
9 answers

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]\\"
juan
  • 80,295
  • 52
  • 162
  • 195
89
votes
5 answers

Environment.GetFolderPath(...CommonApplicationData) is still returning "C:\Documents and Settings\" on Vista

As I understand it, you're supposed to use the Environment.GetFolderPath method so you have OS independent code... Windows XP uses C:\Documents and Settings\. Windows Vista uses C:\ProgramData and C:\Users. I'm using the code below on a Windows…
blak3r
  • 16,066
  • 16
  • 78
  • 98
83
votes
6 answers

Getting Downloads Folder in C#?

I have made some code that will search directories and display files in a listbox. DirectoryInfo dinfo2 = new DirectoryInfo(@"C:\Users\Hunter\Downloads"); FileInfo[] Files2 = dinfo2.GetFiles("*.sto"); foreach (FileInfo file2 in Files2) { …
Hunter Mitchell
  • 7,063
  • 18
  • 69
  • 116
79
votes
6 answers

What determines the return value of Path.GetTempPath()?

Currently, I use Path.GetTempPath() to figure out where to write my log files, but recently I came across a user's machine where the path returned was not what I expected. Usually, the returned path is C:\Documents and Settings\[userid]\Local…
Andy Blackman
  • 1,235
  • 1
  • 11
  • 14
69
votes
16 answers

Is There A System Defined Environment Variable For Documents Directory?

I know about the %USERPROFILE% system defined environment variable on Windows XP (and Vista and Windows 7). Is there a system defined environment variable pointing to the location of the "My Documents" directory? On XP by default it's…
Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
49
votes
2 answers

What's the difference between SpecialFolder.Desktop and SpecialFolder.DesktopDirectory?

I'm confused about the differences between these two special folders. Here's a code snippet that writes the output of each, but they output the same thing. string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string pathTwo =…
Only Bolivian Here
  • 35,719
  • 63
  • 161
  • 257
47
votes
2 answers

Application's data folder in Mac

What is the equivalent of Window's C:\Users\userName\AppData\Roaming\appName? I need a directory that won't cause permission problems to store the updateable part of my application so I can automatically download and override my content. Thank you.
kambi
  • 3,291
  • 10
  • 37
  • 58
44
votes
4 answers

Find windows folder programmatically in c#

I am writing a program to kill and restart explorer but I don't want to hard code the location because some people install windows in different places (for example I found someone who had it installed in the d:\ drive where the C:\ drive did exist…
Crash893
  • 11,428
  • 21
  • 88
  • 123
41
votes
7 answers

python - Finding the user's "Downloads" folder

I already found this question that suggests to use os.path.expanduser(path) to get the user's home directory. I would like to achieve the same with the "Downloads" folder. I know that this is possible in C#, yet I'm new to Python and don't know if…
Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
33
votes
11 answers

How to programmatically derive Windows Downloads folder "%USERPROFILE%/Downloads"?

In .NET, we can retrieve the paths to 'special folders', like Documents / Desktop etc. Today I tried to find a way to get the path to the 'Downloads' folder, but it's not special enough it seems. I know I can just do 'C:\Users\Username\Downloads',…
Maestro
  • 9,046
  • 15
  • 83
  • 116
28
votes
1 answer

What is the WiX equivilent of Environment.SpecialFolder.ApplicationData from .NET?

I need to install a file into the Environment.SpecialFolder.ApplicationData folder, which differs between XP and Vista. Is there a built in way to reference the correct folder in WiX or will I have to use conditional checks for OS and do it…
Davy8
  • 30,868
  • 25
  • 115
  • 173
26
votes
5 answers

As a developer, how should I use the special folders in Windows Vista (and Windows 7)?

Where should I save data related to my application? Where should I save configuration files? Where should I save temporary files? Should I do it in "Documents"? "AppData"? Etc... What is the best practice for saving data to the disk (I guess, best…
Nestor
  • 13,706
  • 11
  • 78
  • 119
22
votes
4 answers

Set location of Special Folders with PowerShell

As administrator, I want to change the default location of special folders (Documents, Music, Downloads…) to a different path. I can do this manually, but I would like to have a PowerShell script to do that. Is there any PS Object that provides…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
20
votes
4 answers

Accessing %appdata% with VB.NET

How can you access files in %appdata% through VB.NET? For example, C:\Users\Kuzon\AppData\Roaming\program. How would I access that file, but on another Windows 7 machine? Also, how would you do it on Windows XP? I believe it is %Application Data%.
Kuzon
  • 782
  • 5
  • 20
  • 49
17
votes
1 answer

How do get the path of Program Files regardless of the architecture of the target machine

I'm programming in C#/.NET. I want to be able to return the Program Files directory from the target machine no matter what the architecture of the target machine is. To clarify, I want it to return C (or whatever drive the OS is on):/Program Files…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
1
2 3
13 14