C WinForm讀寫INI檔案

2022-02-27 02:15:41 字數 380 閱讀 7895

作應用系統開發時,管理配置是必不可少的。例如資料庫伺服器的配置、安裝和更新配置等等。由於xml的興起,現在的配置檔案大都是以xml文件來儲存。比如visual studio.net自身的配置檔案mashine.config,asp.net的配置檔案web.config,都是xml的格式。

傳統的配置檔案ini已有被xml檔案逐步代替的趨勢,但對於簡單的配置,ini檔案還是有用武之地的,尤其現在綠色軟體的流行,越來越多的程式將自己的一些配置資訊儲存到了ini檔案中。ini檔案其實就是乙個文字檔案,它有固定的格式,節section的名字用括起來,然後換行說明key的值:

[section]

key=value

讀取ini

trycatch (exception ex)

INI檔案讀寫

一 有必要了解ini檔案的結構 注釋 小節名 關鍵字 值 ini檔案允許有多個小節,每個小節又允許有多個關鍵字,後面是該關鍵字的值。值的型別有三種 字串 整型數值和布林值。其中字串存貯在ini檔案中時沒有引號,布林真值用1表示,布林假值用0表示。注釋以分號 開頭。二 定義 1 在inte ce的us...

讀寫ini檔案

using system using system.io using system.text using system.configuration using system.runtime.interopservices using system.collections.specialized us...

讀寫ini檔案

using system using system.io using system.text using system.configuration using system.runtime.interopservices using system.collections.specialized us...