Windows uses an enumeration of special folder names to make it easier to find commonly used folders. Without this mechanism, we’d have to jump through a lot more hoops to determine this information since it is user dependent. I was trying to use a special folder as the root of a path for some common files shared by multiple programs that I am working on.
(Squirrel!) I wonder where all these paths point to on my machine? Time to bang out some code to see. I don’t want users to be able to easily screw up my files so maybe I should pick a hidden folder to add some (little) protection.
Special Folder Name | Value on 64-bit machine | Attributes |
---|---|---|
AdminTools | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools | RO |
ApplicationData | C:\Users\{username}\AppData\Roaming | |
CDBurning | ||
CommonAdminTools | C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools | RO |
CommonApplicationData | C:\ProgramData | H |
CommonDesktopDirectory | C:\Users\Public\Desktop | H, RO |
CommonDocuments | C:\Users\Public\Documents | RO |
CommonMusic | C:\Users\Public\Music | RO |
CommonOemLinks | ||
CommonPictures | C:\Users\Public\Pictures | RO |
CommonProgramFiles | C:\Program Files (x86)\Common Files | |
CommonProgramFilesX86 | C:\Program Files (x86)\Common Files | |
CommonPrograms | C:\ProgramData\Microsoft\Windows\Start Menu\Programs | RO |
CommonStartMenu | C:\ProgramData\Microsoft\Windows\Start Menu | RO |
CommonStartup | C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup | RO |
CommonTemplates | C:\ProgramData\Microsoft\Windows\Templates | |
CommonVideos | C:\Users\Public\Videos | RO |
Cookies | C:\Users\{username}\AppData\Local\Microsoft\Windows\INetCookies | H, Sys |
Desktop | C:\Users\{username}\Desktop | RO |
DesktopDirectory | C:\Users\{username}\Desktop | RO |
Favorites | C:\Users\{username}\Favorites | RO |
Fonts | C:\Windows\Fonts | RO, Sys |
History | C:\Users\{username}\AppData\Local\Microsoft\Windows\History | Sys |
InternetCache | C:\Users\{username}\AppData\Local\Microsoft\Windows\INetCache | H, Sys |
LocalApplicationData | C:\Users\{username}\AppData\Local | |
LocalizedResources | ||
MyComputer | ||
MyDocuments | C:\Users\{username}\Documents | RO |
MyMusic | C:\Users\{username}\Music | RO |
MyPictures | C:\Users\{username}\Pictures | RO |
MyVideos | C:\Users\{username}\Videos | RO |
NetworkShortcuts | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Network Shortcuts | |
Personal | C:\Users\{username}\Documents | RO |
PrinterShortcuts | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Printer Shortcuts | |
ProgramFiles | C:\Program Files (x86) | RO |
ProgramFilesX86 | C:\Program Files (x86) | RO |
Programs | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs | RO |
Recent | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent | RO |
Resources | C:\Windows\resources | |
SendTo | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\SendTo | RO |
StartMenu | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu | RO |
Startup | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup | RO |
System | C:\Windows\system32 | |
SystemX86 | C:\Windows\SysWOW64 | |
Templates | C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Templates | |
UserProfile | C:\Users\{username} | |
Windows | C:\Windows |
- H – Directories marked with this attribute do not appear in an ordinary directory listing.
- RO – Applications cannot delete this folder, but applications can create and delete files from that directory.
- Sys – Directory that the operating system uses a part of or uses exclusively.
If you are curious, this is the application I used to determine my values.
using System; using System.Collections.Generic; using System.IO; namespace SpecialFolder { class Program { static void Main(string[] args) { IList<string> folders = new List<String>() { "AdminTools", "ApplicationData", "CDBurning", "CommonAdminTools", "CommonApplicationData", "CommonDesktopDirectory", "CommonDocuments", "CommonMusic", "CommonOemLinks", "CommonPictures", "CommonProgramFiles", "CommonProgramFilesX86", "CommonPrograms", "CommonStartMenu", "CommonStartup", "CommonTemplates", "CommonVideos", "Cookies", "Desktop", "DesktopDirectory", "Favorites", "Fonts", "History", "InternetCache", "LocalApplicationData", "LocalizedResources", "MyComputer", "MyDocuments", "MyMusic", "MyPictures", "MyVideos", "NetworkShortcuts", "Personal", "PrinterShortcuts", "ProgramFiles", "ProgramFilesX86", "Programs", "Recent", "Resources", "SendTo", "StartMenu", "Startup", "System", "SystemX86", "Templates", "UserProfile", "Windows" }; // Coded to create a Markdown format table in console. Console.WriteLine("|Special Folder Name| Value on 64-bit machine| Attributes |"); Console.WriteLine("|--|--|--|"); foreach (string folder in folders) { Environment.SpecialFolder specFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), folder); string envFolder = Environment.GetFolderPath(specFolder); if (String.IsNullOrWhiteSpace(envFolder)) { Console.WriteLine($"| {folder} | | |"); continue; } string attr = (File.GetAttributes(envFolder) & FileAttributes.Hidden) > 0 ? "H" : ""; if ((File.GetAttributes(envFolder) & FileAttributes.ReadOnly) > 0) { if (attr == "") { attr = "RO"; } else { attr += ", RO"; } } if ((File.GetAttributes(envFolder) & FileAttributes.System) > 0) { if (attr == "") { attr = "Sys"; } else { attr += ", Sys"; } } string s = $"| {folder} | {Environment.GetFolderPath(specFolder)} | {attr} |"; // Replace "xxxxx" with your username to hide output. If you don't care, remove the following line. s = s.Replace("xxxxx", "\\{username}"); Console.WriteLine(s); } } } }