国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

[c#]:如何在C#中讀寫INI文件(五)

2024-07-21 02:19:25
字體:
供稿:網(wǎng)友

this.controls.addrange ( new system.windows.forms.control [ ] {

this.button3 ,

this.textbox4 ,

this.textbox3 ,

this.textbox2 ,

this.button2 ,

this.textbox1 ,

this.button1 ,

this.label3 ,

this.label2 ,

this.label1 } ) ;

this.maximizebox = false ;

this.name = "form1" ;

this.text = "c#操作ini文件--寫操作" ;

this.resumelayout ( false ) ;

}

[stathread]

static void main ( )

{

application.run ( new form1 ( ) ) ;

}

private void button1_click ( object sender , system.eventargs e )

{

openfiledialog1.showdialog ( ) ;

textbox1.text = openfiledialog1.filename ;

}

//寫入ini文件

private void button2_click ( object sender , system.eventargs e )

{

string filename = textbox1.text ;

string section = textbox2.text ;

string key = textbox3.text ;

string keyvalue = textbox4.text ;

writeprivateprofilestring ( section , key , keyvalue , filename ) ;

messagebox.show ( "成功寫入ini文件!" , "信息" ) ;

}

//讀取指定ini文件的特定段落中的關鍵字的數(shù)值

private void button3_click ( object sender , system.eventargs e )

{

stringbuilder temp = new stringbuilder ( 255 ) ;

string filename = textbox1.text ;

string section = textbox2.text ;

string key = textbox3.text ;

int i = getprivateprofilestring ( section , key ,

"無法讀取對應數(shù)值!" , emp , 255 , filename ) ;

//顯示讀取的數(shù)值

textbox4.text = temp.tostring ( ) ;

}

}

}


總結



通過上面的這些介紹,可以看成c#操作ini文件的過程,其實就是c#調(diào)用win32的api函數(shù)的過程。掌握了如何在c#申明win32的api函數(shù),再來操作ini就顯得非常簡單。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 江安县| 屏东市| 兴和县| 尚志市| 巢湖市| 海丰县| 忻城县| 石河子市| 瑞昌市| 宝丰县| 林州市| 宁武县| 商水县| 边坝县| 白银市| 灵寿县| 汶川县| 东海县| 涡阳县| 成武县| 精河县| 太湖县| 安仁县| 沾益县| 延长县| 宁强县| 泊头市| 贡嘎县| 定州市| 柏乡县| 滕州市| 鹤庆县| 昭觉县| 泽州县| 漯河市| 开阳县| 萝北县| 石首市| 汉源县| 海南省| 香港 |