Easy to use cfg / ini configuration library for .NET.
You can use SharpConfig to read, modify and save configuration files and streams, in either text or binary format.
Minimalistic, fully portable (.NET Standard 2.0), zero package dependencies.
- .NET CLI:
> dotnet add package sharpconfig - Package Manager:
> NuGet\Install-Package sharpconfig - Download latest
# An example configuration:
[General]
# a comment
SomeString = Hello World!
SomeInteger = 10 # an inline comment
SomeFloat = 20.05
SomeBoolean = true
SomeArray = { 1, 2, 3 }
Day = Monday
[Person]
Name = Peter
Age = 50To read these values, your C# code would look like:
var config = Configuration.LoadFromFile("sample.cfg");
var section = config["General"];
string someString = section["SomeString"].StringValue;
int someInteger = section["SomeInteger"].IntValue;
float someFloat = section["SomeFloat"].FloatValue;
bool someBool = section["SomeBoolean"].BoolValue;
int[] someIntArray = section["SomeArray"].IntValueArray;
string[] someStringArray = section["SomeArray"].StringValueArray;
DayOfWeek day = section["Day"].GetValue<DayOfWeek>();
// Entire user-defined objects can be created from sections and vice versa.
var person = config["Person"].ToObject<Person>();
// ...The full documentation is available on the website.