Read file string

PureSc0pe

Well-known member
Joined
Mar 17, 2004
Messages
161
Location
Arizona
I have a server config file that I need to write to. Also, when the program loads, it needs to read whats in the config file and display the info back to the textboxes.

What needs to be written to the server config.ini is typed in a textbox. Also I need to write whether a checkbox is checked.

I have the inireader.vb, So I need for example

Server IP: 127.0.0.1 <== in a textbox
Server Port: 29018 <== in a textbox
Server Pass: hello123 <== in a textbox

Config File:
Server IP=
Server Port=
Server Pass=

I believe it would be something like this...but it doesnt work, tho no errors.

In the button click, Id have:
ini.Write(ToString, "Server IP=", TextBox1.Text)

In form1_load
TextBox1.Text = ini.ReadString, "LoginName")

That is for a TextBox, how would I do it for a CheckBox as well?

Thanks.
 
I use this :

Code:
StreamWriter sw = new StreamWriter(path);
sw.WriteLine("Config File :");
sw.WriteLine("Server IP=" + txtServIp.Text);
sw.WriteLine("Server Port=" + txtServPort.Text);
sw.WriteLine("Server Pass=" + txtServPass.Text);
sw.Flush();
sw.Close();
Should work for you as well.
 
Back
Top