Write an array from textbox to a textf file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • o M E G a
    New Member
    • Jun 2011
    • 1

    Write an array from textbox to a textf file

    Hi dear BYTES members :
    I have a probelm when writting in a text file i have a string
    of 14 numbers and they change evey time with a space between them but the probelm every time it erase the previous line and write a new one until i find only the last line in the text file :( plz help me
    the c# code :
    Code:
    string path = @"D:\newS_R.txt";
                    
                    TextWriter tw = new StreamWriter(path);
                    tw.WriteLine(textBox46.Text + " " + textBox45.Text + " " + textBox44.Text + " " + textBox43.Text + " " + textBox42.Text + " " + textBox41.Text + " " + textBox40.Text + " " + textBox39.Text + " " + textBox38.Text + " " + textBox37.Text + " " + textBox33.Text + " " + textBox34.Text + " " + textBox35.Text + " " + textBox36.Text + "" + Environment.NewLine);
                    tw.Close();
  • MrWoff
    New Member
    • Jun 2011
    • 2

    #2
    Code:
    tw.WriteLine(
    textBox46.Text + " " + textBox
    45.Text + " " + textBox44.Text
     + " " + textBox43.Text +
     " " + textBox42.Text + "
     " + textBox41.Text + " "
     + textBox40.Text + " " +
     textBox39.Text + " " + t
    extBox38.Text + " " + textBox3
    7.Text + " " + textBox33.Text&
    nbsp;+ " " + textBox34.Text +&
    nbsp;" " + textBox35.Text + "&
    nbsp;" + textBox36.Text + "\n");

    Comment

    • kosaks
      New Member
      • May 2010
      • 10

      #3
      Hello

      try this. add "true" as a second parameter in your TextWriter class.

      TextWriter tw = new StreamWriter(pa th,true);

      Im not sure of this but i think it will work. It will append your text file. instead of erasing the old text in it, it will just add a new line to the text file.

      Regards

      Comment

      Working...