The XDG Base Directory specification is a standard created by freedesktop.org that standardizes the location of storing application files.
This allows users to have less clutter in their home directories, and allows programmers to not have to hard-code directories.
All operating systems that are supported by .NET (Windows, macOS, Linux, FreeBSD at the time of writing) are supported.
For all base directory files, the directories are resolved as follows:
-
The respective XDG_* enivronment variable
will always be used if specified
-
- Operating systemd dependent fallback:
-
Windows
Use Known Folders.
-
macOS
Follow the Apple documentation on application-specific files.
-
Linux/FreeBSD
Follow the XDG Base Directory specification.
Base directory for data files.
A single base directory relative to which user-specifc data files should be written.
If XDG_DATA_HOME is set, the directory specified.
Else,
-
Windows
%LOCALAPPDATA%
-
macOS
$HOME/Library/Application Support
-
Linux/FreeBSD
$HOME/.local/share
Base directory for configuration files.
A single base directory relative to which user-specifc configuration files should be written.
If XDG_CONFIG_HOME is set, the directory specified.
Else,
-
Windows
%LOCALAPPDATA%
-
macOS
$HOME/Library/Application Support
-
Linux/FreeBSD
$HOME/.config
Base directory for state data.
A single base directory relative to which user-specifc state data should be written.
If XDG_STATE_HOME is set, the directory specified.
Else,
-
Windows
%LOCALAPPDATA%
-
macOS
$HOME/Library/Application Support
-
Linux/FreeBSD
$HOME/.local/state
Base directory for executable files.
A single base directory relative to which user-specifc executable files should be written.
If XDG_BIN_HOME is set, the directory specified.
Else,
-
Windows
null
Windows does not support this by default.
-
macOS
null
macOS does not support this by default.
-
Linux/FreeBSD
$HOME/.local/bin
NOTE: This is not an XDG standard but a de facto standard.
A list of directories to search for data files.
A set of preference-ordered base directories to which data files should be searched.
If XDG_DATA_DIRS is set, a list of the directories specified.
Else,
-
Windows
%APPADATA%,
%ProgramData%
-
macOS
/Library/Application Support
-
Linux/FreeBSD
/usr/local/share/,
/usr/share/
A list of directories to look for configuration files.
A set of preference-ordered base directories to which configuration files should be searched.
If XDG_CONFIG_DIRS is set, a list of the directories specified.
Else,
-
Windows
%ProgramData%,
%APPADATA%
-
macOS
~/Library/Preferences,
/Library/Application Support,
/Library/Preferences
-
Linux/FreeBSD
/etc/xdg
This is typically not used, for most use cases ConfigHome should be used instead.
Base directory for non-essential data.
A single base directory relative to which user-specifc non-essential data should be written.
If XDG_CACHE_HOME is set, the directory specified.
Else,
-
Windows
%LOCALAPPDATA%\cache
-
macOS
$HOME/Library/Caches
-
Linux/FreeBSD
$HOME/.cache
Base directory for runtime-specific files.
A single base directory relative to which user-specifc runtime files should be written.
If XDG_RUNTIME_DIR is set, the directory specified.
Else,
-
Windows
%LOCALAPPDATA%
-
macOS
$HOME/Library/Application Support
-
Linux/FreeBSD
/run/user/$UID