Install
dotnet add package SharpConfig --version 4.0.0
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
SharpConfig
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.
Install
- .NET CLI:
> dotnet add package sharpconfig - Package Manager:
> NuGet\Install-Package sharpconfig - Download latest
Example
# 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 = 50
To 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>();
// ...
Documentation
The full documentation is available on the website.
Changes from Previous Version
v3.2.9.1v4.0.0
Added Frameworks
net10.0
Removed Frameworks
.NETFramework2.0.NETFramework3.5.NETFramework4.0.NETFramework4.5.NETFramework4.6.1
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.