[c#]:如何在C#中读写INI文件(四)
来源:互联网 发布:shadow defender 知乎 编辑:程序博客网 时间:2024/05/18 20:10
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
this.button2.Text = "写入INI文件" ;
this.button2.Click += new System.EventHandler ( this.button2_Click ) ;
this.textBox2.Location = new System.Drawing.Point ( 160 , 62 ) ;
this.textBox2.Name = "textBox2" ;
this.textBox2.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox2.TabIndex = 5 ;
this.textBox2.Text = "" ;
this.textBox3.Location = new System.Drawing.Point ( 160 , 94 ) ;
this.textBox3.Name = "textBox3" ;
this.textBox3.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox3.TabIndex = 6 ;
this.textBox3.Text = "" ;
this.textBox4.Location = new System.Drawing.Point ( 160 , 128 ) ;
this.textBox4.Name = "textBox4" ;
this.textBox4.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox4.TabIndex = 7 ;
this.textBox4.Text = "" ;
this.label1.Location = new System.Drawing.Point ( 56 , 62 ) ;
this.label1.Name = "label1" ;
this.label1.TabIndex = 8 ;
this.label1.Text = "段落名称:" ;
this.label2.Location = new System.Drawing.Point ( 66 , 96 ) ;
this.label2.Name = "label2" ;
this.label2.TabIndex = 9 ;
this.label2.Text = "关键字:" ;
this.label3.Location = new System.Drawing.Point ( 42 , 130 ) ;
this.label3.Name = "label3" ;
this.label3.TabIndex = 10 ;
this.label3.Text = "关键字数值:" ;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat ;
this.button3.Location = new System.Drawing.Point ( 208 , 168 ) ;
this.button3.Name = "button3" ;
this.button3.Size = new System.Drawing.Size ( 98 , 30 ) ;
this.button3.TabIndex = 11 ;
this.button3.Text = "读取INI数值" ;
this.button3.Click += new System.EventHandler ( this.button3_Click ) ;
this.openFileDialog1.Filter = "INI 文件|*.INI" ;
this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ;
this.ClientSize = new System.Drawing.Size ( 366 , 217 ) ;
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文件的特定段落中的关键字的数值
private void button3_Click ( object sender , System.EventArgs e )
中读写INI文件(四)';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
this.button2.TabIndex = 3 ; this.button2.Text = "写入INI文件" ;
this.button2.Click += new System.EventHandler ( this.button2_Click ) ;
this.textBox2.Location = new System.Drawing.Point ( 160 , 62 ) ;
this.textBox2.Name = "textBox2" ;
this.textBox2.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox2.TabIndex = 5 ;
this.textBox2.Text = "" ;
this.textBox3.Location = new System.Drawing.Point ( 160 , 94 ) ;
this.textBox3.Name = "textBox3" ;
this.textBox3.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox3.TabIndex = 6 ;
this.textBox3.Text = "" ;
this.textBox4.Location = new System.Drawing.Point ( 160 , 128 ) ;
this.textBox4.Name = "textBox4" ;
this.textBox4.Size = new System.Drawing.Size ( 176 , 21 ) ;
this.textBox4.TabIndex = 7 ;
this.textBox4.Text = "" ;
this.label1.Location = new System.Drawing.Point ( 56 , 62 ) ;
this.label1.Name = "label1" ;
this.label1.TabIndex = 8 ;
this.label1.Text = "段落名称:" ;
this.label2.Location = new System.Drawing.Point ( 66 , 96 ) ;
this.label2.Name = "label2" ;
this.label2.TabIndex = 9 ;
this.label2.Text = "关键字:" ;
this.label3.Location = new System.Drawing.Point ( 42 , 130 ) ;
this.label3.Name = "label3" ;
this.label3.TabIndex = 10 ;
this.label3.Text = "关键字数值:" ;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat ;
this.button3.Location = new System.Drawing.Point ( 208 , 168 ) ;
this.button3.Name = "button3" ;
this.button3.Size = new System.Drawing.Size ( 98 , 30 ) ;
this.button3.TabIndex = 11 ;
this.button3.Text = "读取INI数值" ;
this.button3.Click += new System.EventHandler ( this.button3_Click ) ;
this.openFileDialog1.Filter = "INI 文件|*.INI" ;
this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ;
this.ClientSize = new System.Drawing.Size ( 366 , 217 ) ;
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文件的特定段落中的关键字的数值
private void button3_Click ( object sender , System.EventArgs e )
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- [c#]:如何在C#中读写INI文件(四)
- [c#]:如何在C#中读写INI文件(四)
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- [c#]:如何在C#中读写INI文件(一)
- [c#]:如何在C#中读写INI文件(二)
- [c#]:如何在C#中读写INI文件(三)
- [c#]:如何在C#中读写INI文件(五)
- Win2k Server下Oracle 9iAS安装报告(二)
- 转贴自JoyASP:.NET框架(一)
- 几十个实用的PL/SQL(3)
- 深入讲解 ASP+ 验证
- Oracle 10g for Windows 32bit安装图解
- [c#]:如何在C#中读写INI文件(四)
- T-SQL 生成一个简易的 公历年历 T-SQL 含日期所在月及
- 从App到Application (CSDN)
- 手工转移数据库Step By Step
- 一段log execption 的代码
- 伟大的解决方案—DataWindow.Net(一)
- 大数据量下的分页
- 如何在Windows 2000环境中Kill掉单个Oracle线程
- 使用C#拷贝String到struct