Environment.SpecialFolder on Windows, Linux and OS X

While developing Pkcs11Admin – multiplatform application written in C# – I was trying to figure out where to store log file so it can be easily reached by the user on all supported operating systems – Windows, Linux and Mac OS X.

To avoid hardcoding I wanted to use System.Environment.SpecialFolder enumeration but I was not quite sure which member to choose because the documentation does not contain the actual paths. So I have created simple test application which dumps these paths and executed it on Windows 8.1 with .NET Framework 4.5, on Ubuntu 14.04 LTS with Mono 3.2.8 and on Mac OS X 10.10.1 Yosemite with Mono 3.10.0. Here are the results:

System.Environment.SpecialFolder.AdminTools
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsStart MenuProgramsAdministrative Tools
Linux:
OS X:
System.Environment.SpecialFolder.AdminTools
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsStart MenuProgramsAdministrative Tools
Linux:
OS X:
System.Environment.SpecialFolder.ApplicationData
Windows: C:UsersjariqAppDataRoaming
Linux: /home/jariq/.config
OS X: /Users/jariq/.config
System.Environment.SpecialFolder.CDBurning
Windows: C:UsersjariqAppDataLocalMicrosoftWindowsBurnBurn
Linux:
OS X:
System.Environment.SpecialFolder.CommonAdminTools
Windows: C:ProgramDataMicrosoftWindowsStart MenuProgramsAdministrative Tools
Linux:
OS X:
System.Environment.SpecialFolder.CommonApplicationData
Windows: C:ProgramData
Linux: /usr/share
OS X: /usr/share
System.Environment.SpecialFolder.CommonDesktopDirectory
Windows: C:UsersPublicDesktop
Linux:
OS X:
System.Environment.SpecialFolder.CommonDocuments
Windows: C:UsersPublicDocuments
Linux:
OS X:
System.Environment.SpecialFolder.CommonMusic
Windows: C:UsersPublicMusic
Linux:
OS X:
System.Environment.SpecialFolder.CommonOemLinks
Windows:
Linux:
OS X:
System.Environment.SpecialFolder.CommonPictures
Windows: C:UsersPublicPictures
Linux:
OS X:
System.Environment.SpecialFolder.CommonProgramFiles
Windows: C:Program FilesCommon Files
Linux:
OS X:
System.Environment.SpecialFolder.CommonProgramFilesX86
Windows: C:Program Files (x86)Common Files
Linux:
OS X:
System.Environment.SpecialFolder.CommonPrograms
Windows: C:ProgramDataMicrosoftWindowsStart MenuPrograms
Linux:
OS X:
System.Environment.SpecialFolder.CommonStartMenu
Windows: C:ProgramDataMicrosoftWindowsStart Menu
Linux:
OS X:
System.Environment.SpecialFolder.CommonStartup
Windows: C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup
Linux:
OS X:
System.Environment.SpecialFolder.CommonTemplates
Windows: C:ProgramDataMicrosoftWindowsTemplates
Linux: /usr/share/templates
OS X: /usr/share/templates
System.Environment.SpecialFolder.CommonVideos
Windows: C:UsersPublicVideos
Linux:
OS X:
System.Environment.SpecialFolder.Cookies
Windows: C:UsersjariqAppDataLocalMicrosoftWindowsINetCookies
Linux:
OS X:
System.Environment.SpecialFolder.Desktop
Windows: C:UsersjariqDesktop
Linux: /home/jariq/Desktop
OS X: /Users/jariq/Desktop
System.Environment.SpecialFolder.DesktopDirectory
Windows: C:UsersjariqDesktop
Linux: /home/jariq/Desktop
OS X: /Users/jariq/Desktop
System.Environment.SpecialFolder.Favorites
Windows: C:UsersjariqFavorites
Linux:
OS X: /Users/jariq/Library/Favorites
System.Environment.SpecialFolder.Fonts
Windows: C:WINDOWSFonts
Linux: /home/jariq/.fonts
OS X: /Users/jariq/Library/Fonts
System.Environment.SpecialFolder.History
Windows: C:UsersjariqAppDataLocalMicrosoftWindowsHistory
Linux:
OS X:
System.Environment.SpecialFolder.InternetCache
Windows: C:UsersjariqAppDataLocalMicrosoftWindowsINetCache
Linux:
OS X: /Users/jariq/Library/Caches
System.Environment.SpecialFolder.LocalApplicationData
Windows: C:UsersjariqAppDataLocal
Linux: /home/jariq/.local/share
OS X: /Users/jariq/.local/share
System.Environment.SpecialFolder.LocalizedResources
Windows:
Linux:
OS X:
System.Environment.SpecialFolder.MyComputer
Windows:
Linux:
OS X:
System.Environment.SpecialFolder.MyDocuments
Windows: C:UsersjariqDocuments
Linux: /home/jariq
OS X: /Users/jariq
System.Environment.SpecialFolder.MyMusic
Windows: C:UsersjariqMusic
Linux: /home/jariq/Music
OS X: /Users/jariq/Music
System.Environment.SpecialFolder.MyPictures
Windows: C:UsersjariqPictures
Linux: /home/jariq/Pictures
OS X: /Users/jariq/Pictures
System.Environment.SpecialFolder.MyVideos
Windows: C:UsersjariqVideos
Linux: /home/jariq/Videos
OS X: /Users/jariq/Videos
System.Environment.SpecialFolder.NetworkShortcuts
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsNetwork Shortcuts
Linux:
OS X:
System.Environment.SpecialFolder.Personal
Windows: C:UsersjariqDocuments
Linux: /home/jariq
OS X: /Users/jariq
System.Environment.SpecialFolder.PrinterShortcuts
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsPrinter Shortcuts
Linux:
OS X:
System.Environment.SpecialFolder.ProgramFiles
Windows: C:Program Files
Linux:
OS X: /Applications
System.Environment.SpecialFolder.ProgramFilesX86
Windows: C:Program Files (x86)
Linux:
OS X:
System.Environment.SpecialFolder.Programs
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsStart MenuPrograms
Linux:
OS X:
System.Environment.SpecialFolder.Recent
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsRecent
Linux:
OS X:
System.Environment.SpecialFolder.Resources
Windows: C:WINDOWSresources
Linux:
OS X:
System.Environment.SpecialFolder.SendTo
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsSendTo
Linux:
OS X:
System.Environment.SpecialFolder.StartMenu
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsStart Menu
Linux:
OS X:
System.Environment.SpecialFolder.Startup
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup
Linux:
OS X:
System.Environment.SpecialFolder.System
Windows: C:WINDOWSsystem32
Linux:
OS X:
System.Environment.SpecialFolder.SystemX86
Windows: C:WINDOWSSysWOW64
Linux:
OS X:
System.Environment.SpecialFolder.Templates
Windows: C:UsersjariqAppDataRoamingMicrosoftWindowsTemplates
Linux: /home/jariq/Templates
OS X: /Users/jariq/Templates
System.Environment.SpecialFolder.UserProfile
Windows: C:Usersjariq
Linux: /home/jariq
OS X: /Users/jariq
System.Environment.SpecialFolder.Windows
Windows: C:WINDOWS
Linux:
OS X:

For now I have ended up using Environment.SpecialFolder.MyDocuments member because it points to the directories which are easily accessible even by a casual user.

Published by

Jaroslav IMRICH

I am former system administrator, now software engineer, open source developer enjoying writing software in C and C# languages, self-proclaimed PKCS#11 guru and guitar addict.