App.config中与.ini文件中与、文件、App、config

2023-09-03 06:28:03 作者:〆青春献给了课桌

我审查一个.NET项目,我碰到的配置.ini文件的一些pretty的大量使用。我更preFER使用的app.config文件,而不是,但在此之前我跳和上做文章了,这跟开发者,我不知道是否有任何正当的理由了的app.config青睐.ini文件 解决方案

那么,平均而言,.ini文件可能更紧凑的方式更具可读性人类。 XML是一个有点疼痛阅读,其相当冗长。

不过,当然的app.config是支持.NET,拥有大量的钩和方式来做事的标准.NET配置机制。如果你去与.ini文件,你基本上是滚动自己所有的方式。的重新发明轮子的经典案例。

话又说回来:有没有可能这是.NET之前开始其生命的一个项目?或现有的pre-.NET的Windows应用程序,其中.ini文件是要走的路的端口?

没有什么内在的错误.ini文件,我认为 - 他们只是没有真正支载在.NET中了,你对你自己的扩展它们,处理它们的等它​​当然是一个难倒如果你需要把船上外界的帮助 - 几乎没有任何.NET开发人员已经暴露在.ini文件,而.NET配置系统是相当广泛的认识和了解。

I'm reviewing a .NET project, and I came across some pretty heavy usage of .ini files for configuration. I would much prefer to use app.config files instead, but before I jump in and make an issue out of this with the devs, I wonder if there are any valid reasons to favor .ini files over app.config?

解决方案

Well, on average, .INI files are probably more compact and in a way more readable to humans. XML is a bit of a pain to read, and its quite verbose.

如何新建ini文件

However, app.config of course is the standard .NET configuration mechanism that is supported in .NET and has lots of hooks and ways to do things. If you go with .INI files, you're basically "rolling your own all the way". Classic case of "reinventing the wheel".

Then again: is there any chance this is a project that started its life before .NET ? Or a port of an existing pre-.NET Windows app where .INI files were the way to go?

There's nothing inherently wrong with .INI files I think - they're just not really suported in .NET anymore, and you're on your own for extending them, handling them etc. And it certainly is a "stumper" if you ever need to bring outside help on board - hardly any .NET developer will have been exposed to .INI files while the .NET config system is fairly widely known and understood.