0

i want save data from textbox c# into file .cfg in the next line. then every time I add it again it will continue to the next line again and again

example: In the file there is data like this:

a = 1
b = 2
c = 3

and I want to add from the c # textbox to the file like this:

a=4
b=5
c=6

after that I want the file to look like this:

a = 1
b = 2
c = 3
a = 4
b = 5
c = 6

i've try code like this:

string writerfile = @"D:\file.cfg";
using (StreamWriter writer = new StreamWriter(writerfile))
{
writer.WriteLine("a=" + textbox1.Text);
writer.WriteLine("b=" + textbox2.Text);
writer.WriteLine("c=" + textbox3.Text);
}

this code run. but not i want.

so, please help me. thanks

Fayy
  • 9
  • 7
  • Use this overload instead `using (StreamWriter writer = new StreamWriter(weiterfile, true))` where `true` to inform the writer to append the output. –  Nov 13 '19 at 07:24
  • IT'S WORKKKKKKK. AH. THANK YOU SO MUCHH. im from indonesia btw – Fayy Nov 13 '19 at 07:35
  • Most welcome. Viva Indonesia. –  Nov 13 '19 at 07:37

0 Answers0