Friday, 22 October 2021

Read INI file ASP.Net MVC C#

 Install ini reference 

> nuget install ini-parser
                or
PM> Install-Package ini-parser


If you are using Visual Studio, you can download the NuGet Package Manager extension that will allow adding the NuGet dependency for your project.

Getting Started

All code examples expect the following using clauses:

using IniParser;
using IniParser.Model;

INI data is stored in nested dictionaries, so accessing the value associated to a key in a section is straightforward. Load the data using one of the provided methods.

var parser = new FileIniDataParser();
IniData data = parser.ReadFile("Configuration.ini");

Retrieve the value for a key inside of a named section. Values are always retrieved as strings.

string useFullScreenStr = data["UI"]["fullscreen"];
// useFullScreenStr contains "true"
bool useFullScreen = bool.Parse(useFullScreenStr);

Modify the value in the dictionary, not the value retrieved, and save to a new file or overwrite.

data["UI"]["fullscreen"] = "true";
parser.WriteFile("Configuration.ini", data);
for more information visit : Reference Website
Next Topic


No comments:

Post a Comment