Simple, file-backed configuration handling for .NET applications.
Medo.Config provides a small API for reading and writing application settings and runtime state, with sensible defaults for config file locations on Windows and Linux.
- User configuration with system configuration file as a fallback
- Preserves comments and general formatting when possible
- Thread-safe access
- Separate state file
- Separate recent files handling
Install from NuGet:
dotnet add package Medo.Configusing Medo;
var lastRun = Config.Read("LastRun", DateTime.MinValue);
Config.Write("LastRun", DateTime.UtcNow);See examples/ConfigExample for a minimal usage sample.
See examples/RecentExample for a recent file handling example.
By default, application name is inferred from assembly metadata
(AssemblyProduct, then AssemblyTitle, then assembly name).
On Windows:
- System:
%ProgramData%\[ApplicationName]\[ApplicationName].conf - User:
%AppData%\[ApplicationName]\[ApplicationName].conf - State:
%AppData%\[ApplicationName]\[ApplicationName].state - Recent:
%AppData%\[ApplicationName]\[ApplicationName].recent
On Linux/macOS and other non-Windows platforms:
- System:
/etc/[applicationname]/[applicationname].conf - User:
$XDG_CONFIG_HOME/[applicationname]/[applicationname].conf(or~/.config/[applicationname]/[applicationname].conf) - State:
$XDG_STATE_HOME/[applicationname]/[applicationname].state(or~/.local/state/[applicationname]/[applicationname].state) - Recent:
$XDG_STATE_HOME/[applicationname]/[applicationname].recent(or~/.local/state/[applicationname]/[applicationname].recent)
Note: non-Windows defaults normalize app name to lowercase.
Configuration files use a properties-style text format:
# Sample config
Theme: dark
ItemCount: 100
Path: /opt/b:and=separators are supported- repeated keys are supported (use
ReadMany) - values are stored as UTF-8 (without BOM)
- comments beginning with
#are supported
Recent file storage uses one file name per line in UTF-8 (without BOM) file:
/file1.txt
/file2.txtIf needed, provide explicit paths:
using Medo;
Config.Initialize(
userConfigPath: "/home/app/.config/myapp.conf",
systemConfigPath: "/etc/myapp.conf",
stateConfigPath: "/home/app/.local/state/myapp.state"),
recentPath: "/home/app/.local/state/myapp.recent");Pass null for any path that is not needed.