NavileTech.IniSharpNet
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NavileTech.IniSharpNet --version 1.0.2
NuGet\Install-Package NavileTech.IniSharpNet -Version 1.0.2
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="NavileTech.IniSharpNet" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NavileTech.IniSharpNet" Version="1.0.2" />
<PackageReference Include="NavileTech.IniSharpNet" />
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 NavileTech.IniSharpNet --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NavileTech.IniSharpNet, 1.0.2"
#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 NavileTech.IniSharpNet@1.0.2
#: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=NavileTech.IniSharpNet&version=1.0.2
#tool nuget:?package=NavileTech.IniSharpNet&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
IniSharp
Library for ini configuration file
IniSharp is a .NET library to manage ini configuration file. This repository contains following projects :
- IniSharp (.Net framework of library , now not completed tested)
- IniSharp.Test (.Net framework of test library , now not completed tested)
- IniSharpNet (.NET library)
- IniSharpNet.Test (.NET test library)
- IniSharp.GUI (for GUI test of the .NET library)
Usage :
config.ini
; questo è un commento
# anche questo è un commento
[SEZIONE_1]
campo001=valore1
Campo2=valore002
[SEZIONE_2]
Campo2=valore002
valoreacapo
campo4=
; commento
[SEZIONE_3]
[SEZIONE_4]
; commento
[SEZIONE_5]
campo6=000
C# code :
IniSharp iniSharp = new IniSharp(fullPathFile);
iniSharp.Read();
// output of next line is "SEZIONE_1"
Console.WriteLine(iniSharp.Section[0].Name);
// output of next line is "campo001"
Console.WriteLine(iniSharp.Section[0].Fields[0].Name);
// output of next line is "0"
Console.WriteLine(iniSharp.Section[2].Fields.Count);
// output of next line is "valore002"
Console.WriteLine(iniSharp.Section[1].Fields[0].Lines[0]);
// output of next line is "valoreacapo"
Console.WriteLine(iniSharp.Section[1].Fields[0].Lines[1])
Multiline value are separated by newline.
Multivalue are separated by "," or "|" char.
Campo2=valore002,valoreacapo
IniSharp iniSharp = new IniSharp(fullPathFile);
iniSharp.MultiValueSeparator = MULTIVALUESEPARATOR.COMMA;
or
Campo2=valore002|valoreacapo
IniSharp iniSharp = new IniSharp(fullPathFile);
iniSharp.MultiValueSeparator = MULTIVALUESEPARATOR.PIPE;
Indexer
Set new string throught indexer :
String newValue = "ThisIsANewValue";
// Get/Set indexed value, int and string
// Accessor for string name
iniSharp["SEZIONE_1"]["campo001"][0] = newValue;
// or
// Accessor for int index
iniSharp[0][0][0] = newValue;
Add a new value in next line :
String newValue = "ThisIsANewValue";
IniConfig config = new IniConfig();
config.MULTIVALUESEPARATOR = MULTIVALUESEPARATORLocal;
// Accessor strategy for index
config.BYINDEX = AccessorsStatus.DINAMIC;
// Accessor strategy DYNAMIC for name is not used
// Get/Set indexed value, int and string
// lenght is 1 before set
iniSharp["SEZIONE_1"]["campo001"][1] = newValue;
// now lenght is 2
SetValue\GetValue
// get value if exist , otherwise null
String newGetValue = iniSharpBegin.GetValue(0, 0, 0);
// Set
String newValue = "ThisIsANewValue";
Boolean bSuccess = iniSharpBegin.SetValue(0, 0, 0, newValue);
Limits
- Do not accept char comment at the end of a field value like :
FieldName=FieldValue001 ; SomeComment
"; SomeComment" will be part of field value so use this way to comment a field :
; SomeComment
FieldName=FieldValue001
Load\Write
IniSharp iniSharp = new IniSharp(fi.FullName,config);
iniSharp.Config = config;
iniSharp.Read();
Tech
Here some useful link:
- Wikipedia - Wikipedia page for Ini file
- Fileformat - Fileformat page for Ini file
- C#indexer - How to use CSharp indexer
License
MIT
Free Software, Hell Yeah!
Date
24 feb 2025
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.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.