新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > .Net开发 > Asp.net教程 > 正文:[c#]:如何在C#中读写INI文件(三)

[c#]:如何在C#中读写INI文件(三)

新客网 XKER.COM 2004-07-09 来源: 收藏本文
using System ;

using System.Drawing ;

using System.Collections ;

using System.ComponentModel ;

using System.Windows.Forms ;

using System.Data ;

using System.Runtime.InteropServices ;

using System.Text ;

namespace C_操作INI文件__写操作

{

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.Button button1 ;

private System.Windows.Forms.TextBox textBox1 ;

private System.Windows.Forms.Button button2 ;

private System.Windows.Forms.TextBox textBox2 ;

private System.Windows.Forms.TextBox textBox3 ;

private System.Windows.Forms.TextBox textBox4 ;

private System.Windows.Forms.Label label1 ;

private System.Windows.Forms.Label label2 ;

private System.Windows.Forms.Label label3 ;

private System.Windows.Forms.Button button3 ;

private System.Windows.Forms.OpenFileDialog openFileDialog1 ;

private System.ComponentModel.Container components = null ;

public Form1 ( )

{

InitializeComponent ( ) ;

}

protected override void Dispose ( bool disposing )

{

if ( disposing )

{

if ( components != null )

{

components.Dispose ( ) ;

}

}

base.Dispose ( disposing ) ;

}



[ DllImport ( "kernel32" ) ]

private static extern long WritePrivateProfileString ( string

section ,

string key , string val , string filePath ) ;

[ DllImport ( "kernel32" ) ]

private static extern int GetPrivateProfileString ( string section ,

string key , string def , StringBuilder retVal ,

int size , string filePath ) ;

private void InitializeComponent ( )

{

this.button1 = new System.Windows.Forms.Button ( ) ;

this.textBox1 = new System.Windows.Forms.TextBox ( ) ;

this.button2 = new System.Windows.Forms.Button ( ) ;

this.textBox2 = new System.Windows.Forms.TextBox ( ) ;

this.textBox3 = new System.Windows.Forms.TextBox ( ) ;

this.textBox4 = new System.Windows.Forms.TextBox ( ) ;

this.label1 = new System.Windows.Forms.Label ( ) ;

this.label2 = new System.Windows.Forms.Label ( ) ;

this.label3 = new System.Windows.Forms.Label ( ) ;

this.button3 = new System.Windows.Forms.Button ( ) ;

this.openFileDialog1 = new

System.Windows.Forms.OpenFileDialog ( ) ;

this.SuspendLayout ( ) ;

this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat ;

this.button1.Location = new System.Drawing.Point ( 238 , 20 ) ;

this.button1.Name = "button1" ;

this.button1.Size = new System.Drawing.Size ( 100 , 32 ) ;

this.button1.TabIndex = 0 ;

this.button1.Text = "选择INI文件" ;

this.button1.Click += new System.EventHandler ( this.button1_Click ) ;

this.textBox1.Location = new System.Drawing.Point ( 58 , 22 ) ;

this.textBox1.Name = "textBox1" ;

this.textBox1.Size = new System.Drawing.Size ( 162 , 21 ) ;

this.textBox1.TabIndex = 1 ;

this.textBox1.Text = "" ;

this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat ;

this.button2.Location = new System.Drawing.Point ( 86 , 168 ) ;

this.button2.Name = "button2" ;

this.button2.Size = new System.Drawing.Size ( 98 , 30 ) ;


收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐