dotnet add package MadMilkman.Ini
using MadMilkman.Ini;
using System.Text;
IniFile file = new IniFile(new IniOptions()
{
Encoding = new UTF8Encoding(true),
});
IniSection section = file.Sections.Add("Section name");
section.TrailingComment.Text = "Section trailing comment";
IniKey key = section.Keys.Add("Key name", "Key value ");
key.LeadingComment.Text = "Key leading comment";
var language = file.Sections.Add("语言");
language.TrailingComment.Text = "应用程序语言";
var languageHome = language.Keys.Add("language_home", "zh-cn");
languageHome.LeadingComment.Text = "应用程序首页语言";
var languageAbout = language.Keys.Add("language_about", "US-en");
languageAbout.LeadingComment.Text = "应用程序关于页语言";
var dog = file.Sections.Add("狗");
dog.Keys.Add("耳朵", "两个");
dog.Keys.Add("腿", "两只");
dog.Keys.Add("尾巴", "一个");
dog.Keys.Add("眼睛", "两个");
file.Save("config.ini");
预览
image.png
网友评论