[C #]: How to read the INI file in C # (4)

zhaozj2021-02-16  52

THIS.BUTTON2.TABINDEX = 3;

This.button2.text = "Write ini file";

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 = "Paragraph Name:";

This.Label2.Location = new system.drawing.point (66, 96);

THIS.LABEL2.NAME = "label2";

THIS.LABEL2.TABINDEX = 9;

THIS.LABEL2.TEXT = "Keywords:";

This.Label3.Location = new system.drawing.point (42, 130);

THIS.LABEL3.NAME = "label3";

THIS.Label3.tabindex = 10;

THIS.Label3.Text = "Keyword Numerical:";

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 = "Read INI value";

This.Button3.click = new system.eventhandler (this.button3_click);

This.openfileDialog1.filter = "INI file | * .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 # Operate INI File - Write";

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;

}

// Write into INI file

Private void button2_click (Object Sender, System.Eventargs E)

{

String filename = textbox1.text;

String sext.com2.text;

String key = textBox3.text;

String KeyValue = TextBox4.Text;

WritePrivateProfileString (Section, Key, KeyValue, FileName);

Messagebox.show ("Successful Writing Ini File!", "Information");

}

/ / Read the value of keywords in the specific paragraph of the specified INI file

Private void button3_click (Object Sender, System.Eventargs E)

{

转载请注明原文地址:https://www.9cbs.com/read-22178.html

New Post(0)