PTrampert.IniUtils 2.5.0

dotnet add package PTrampert.IniUtils --version 2.5.0
                    
NuGet\Install-Package PTrampert.IniUtils -Version 2.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PTrampert.IniUtils" Version="2.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PTrampert.IniUtils" Version="2.5.0" />
                    
Directory.Packages.props
<PackageReference Include="PTrampert.IniUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PTrampert.IniUtils --version 2.5.0
                    
#r "nuget: PTrampert.IniUtils, 2.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PTrampert.IniUtils@2.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PTrampert.IniUtils&version=2.5.0
                    
Install as a Cake Addin
#tool nuget:?package=PTrampert.IniUtils&version=2.5.0
                    
Install as a Cake Tool

PTrampert.IniUtils

Lightweight .NET library for reading INI files into a small in-memory model.

PTrampert.IniUtils focuses on a simple, predictable parser with an async API and a few useful options. It exposes an easy-to-use reader (IniReader) and small data types (IniFile, IniSection, IniOptions) that make consuming INI data straightforward.

Features

  • Read INI data asynchronously from a TextReader, Stream, or file path.
  • Preserve multiple values for the same key (duplicate keys append values).
  • Configurable comment character and option to keep empty values.
  • Simple in-memory model: sections (including a root section) with key → values mapping.
  • Small surface area — no external dependencies required by the library itself.
  • Automatic includes resolution (e.g. Include = otherfile.ini).

Install

Install from NuGet (package id: PTrampert.IniUtils):

# install the package
dotnet add package PTrampert.IniUtils

If you consume the project as a package, use the package ID and version that corresponds to the published NuGet package.

Quick start / Usage

Basic usage (from code):

using PTrampert.IniUtils;

var options = new IniOptions();
var reader = new IniReader(options);

// 1) Read from a TextReader (core overload)
using var sr = new StringReader("key1=value1\nkey2=value2");
var iniFromTextReader = await reader.ReadAsync(sr);

// 2) Read from a Stream
using var fs = File.OpenRead("config.ini");
var iniFromStream = await reader.ReadAsync(fs);

// 3) Read directly from a file path
var iniFromFile = await reader.ReadAsync("path/to/config.ini");

// Working with results
var root = iniFromFile.Sections[""]; // root section stored under empty string
if (root.KeyValues.TryGetValue("key1", out var values))
{
    foreach (var v in values)
    {
        Console.WriteLine(v);
    }
}

Optional behaviors controlled by IniOptions:

  • CommentCharacter (char) — change the character that marks a full-line comment (default is ';').
  • KeepEmptyValues (bool) — if true, keys with empty values are kept; otherwise they are ignored.

You can also pass a custom IniSection as the rootSection parameter to any ReadAsync overload to start with a pre-populated root section.

Build and test

From the repository root:

# build
dotnet build

# run tests
dotnet test

The test project uses NUnit and validates parsing behavior across the available ReadAsync overloads.

Contributing

Contributions, bug reports, and pull requests are welcome. Please include tests for new behavior and keep public API changes small and well-documented.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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.

Version Downloads Last Updated
2.5.0 101 2/7/2026
2.4.1 94 1/21/2026
2.4.0 95 1/21/2026
2.3.1 97 1/19/2026
2.3.0 97 1/19/2026
2.2.1 98 1/19/2026
2.2.0 94 1/19/2026
2.1.1 90 1/19/2026
2.1.0 96 1/19/2026
2.0.1 94 1/19/2026
2.0.0 92 1/19/2026
1.1.0 103 1/19/2026
1.0.0 104 1/19/2026