SharpINI 1.1.0
See the version list below for details.
dotnet add package SharpINI --version 1.1.0
NuGet\Install-Package SharpINI -Version 1.1.0
<PackageReference Include="SharpINI" Version="1.1.0" />
paket add SharpINI --version 1.1.0
#r "nuget: SharpINI, 1.1.0"
// Install SharpINI as a Cake Addin #addin nuget:?package=SharpINI&version=1.1.0 // Install SharpINI as a Cake Tool #tool nuget:?package=SharpINI&version=1.1.0
SharpINI - A simple INI Reader/Writer for C#
SharpINI is a simple .NET Standard 2.0 compatible library to parse and write INI strings.
INIs are somehow a problematic format, since there is no global standard like for JSON or XML. There are so many implementations that parse the files using different rules. This library tries to provide an interface with parsing options to parse some of the INI files out there without creating too much complexity.
Flexibility
This library allows the following things to be defined while parsing:
- Space chars
- Line breaks (limited)
- Comment chars (only at the beginning of a line)
- Behaviour when there are multiple sections with the same name
- Behaviour when there are multiple keys in a section with the same name
- Behaviour when there are strings outside of a section (when no section has been started)
- Removing spaces before and after value
General parsing rules
These rules are hard and cannot be changed using parsing options
- Any space at the start of a line is removed
- Any space between the key of a key-value-pair and the
=
is removed - Section titles must not contain closing brackets (
]
) in their name - Any line must be a section title, a key-value pair, an empty line (filled with space) or a comment line
Reading
SharpINI parses the string into the following format:
- Each Section is represented as
Dictionary<string, string>
- The INI file is represented as
Dictionary<string, Dictionary<string, string>>
See Types-section for more information
Basic reading
using SharpINI;
var myINIString = @"[MySection]
Key1=val1
Key2=val2
[MySection2]
Key1=val3
Key2=val4";
var parsed = INIReader.ReadINI(myINIString);
/*parsed:
[
[MySection,
[Key1, val1]
[Key2, val2]
],
[MySection2,
[Key1, val3]
[Key2, val4]
]
]
*/
var key = parsed["MySection"]["Key1"]; // => "val1"
NuGet supports only up to 8000 bytes for the documentation. Please read the full docu on Github
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.