我最近一直在研究我的软件,我一直想知道存储关联数组的最佳方法是什么。
我唯一能想到的就是做这样的事情:
<add key="disks" value="C|1|10,D|2|20,E|1|5,Z|1|3"/>
但这并没有在我的配置文件中提供很多可读性,我希望我的配置文件是可读的,因为它是一个控制台应用程序。
这是因为我编写了一个程序来检查 app.config 文件中指定的磁盘的磁盘空间,但我想要不同磁盘的不同阈值。
你会怎么解决?这是我当前配置文件的一部分。
<!-- DISK FEATURE SETTINGS -->
<!-- Type 1 is threshold by percentage and type 2 is threshold by a certain limit -->
<add key="threshold_type" value="1" />
<add key="threshold_limit" value="0,1" />
<!-- Space_type defines if you want to limit using kilobytes (1), megabytes (2) or gigabytes (3) if using threshold_type 2 -->
<add key="space_type" value="3" />
<!-- Put the disks here delimited by a comma like this: C,D,E -->
<add key="disks" value="C,D,E,Z"/>
<!-- SERVICE FEATURE SETTINGS -->
<!-- Put the services here delimited by a comma like this: C,D,E -->
<add key="services" value="spooler,ekrn,RadeonPro Support Service,TeamViewer6"/>
<!-- Put this on 1 if you want to log your output to a text file -->
<add key="logging" value="1"/>
我想对我的 performancecounter 程序使用相同的原理,该程序使用 perfmon 计数器获取一些数据并将其存储在文本文件中。
我希望人们可以在这里帮助我一点:)