私は最近自分のソフトウェアに取り組んでいて、連想配列を格納するのが最善の方法は何だろうと思っています。
私が思いついた唯一のことは、次のようなことをすることです。
<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"/>
perfmonカウンターを使用してデータを取得し、それをテキストファイルに保存する、パフォーマンスカウンタープログラムにも同じ原則を使用したいと思います。
私は人々がここで少し私を助けてくれることを願っています:)