Reading/writing an INI file(读/写一个INI文件)
问题描述
.NET 框架中是否有可以读/写标准 .ini 文件的类:
Is there any class in the .NET framework that can read/write standard .ini files:
[Section]
<keyname>=<value>
...
Delphi 有 TIniFile 组件,我想知道 C# 是否有类似的东西?
Delphi has the TIniFile component and I want to know if there is anything similar for C#?
推荐答案
.NET 框架的创建者希望您使用基于 XML 的配置文件,而不是 INI 文件.所以不,没有用于读取它们的内置机制.
The creators of the .NET framework want you to use XML-based config files, rather than INI files. So no, there is no built-in mechanism for reading them.
不过,有第三方解决方案可用.
There are third party solutions available, though.
- INI 处理程序可以通过 NuGet 包 获得,例如 INI 解析器.
- 您可以编写自己的 INI 处理程序,这是老式的、费力的方式.它使您可以更好地控制实现,您可以将其用于坏处或好处.参见例如一个使用 C#、P/Invoke 和 Win32 的 INI 文件处理类.
- INI handlers can be obtained as NuGet packages, such as INI Parser.
- You can write your own INI handler, which is the old-school, laborious way. It gives you more control over the implementation, which you can use for bad or good. See e.g. an INI file handling class using C#, P/Invoke and Win32.
这篇关于读/写一个INI文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:读/写一个INI文件
基础教程推荐
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
