我最近一直在我的软件上工作,我一直在想,最好的方法是存储联想阵列。

我唯一可以出来的东西是做这样的事情:

<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程序使用相同的原理,该程序使用完整的次数来获得一些数据并将其存储在文本文件中。

我希望人们可以帮助我有点:)

有帮助吗?

解决方案

我建议您创建自己的配置部分。自定义配置提供了更多可读性和类型安全性。以下是创建自定义配置的链接 http://msdn.microsoft.com/en-us/library/2tw134k3.aspx http://haacked.com/ clustom-configuration -sections-in-3-easy-steps.aspx (旧的,但易于关注)。

其他提示

就标准配置机制适用于XML序列化,最佳(和,恕我直言,WISE)在App.config中存储字典的方式是一个生成的eticetagcode。

您可能希望从system.collection或list <> 中使用Hashtable

下面是哈希特的指针很少, http://www.dotnetperls.com/hashtable http://www.tutorialspoint.com/csharp/charp_hashtable.htm

我希望这有助于帮助!!谢谢:)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top