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文件


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01