Reputation:
private void button1_Click(object sender, EventArgs e) {
String[] bla = File.ReadAllText(@"c:\\chat.csv").Split('|');
for (int i = 0; i < bla.Length; i++) {
textBox1.AppendText(bla[i] + Environment.NewLine);
}
}
This code loads a csv file into textBox1
and splits lines (|). I would like to add text to the csv file with the input of textBox2
. So, the value of textBox2
should be added to the last line in chat.csv
.
waarde1 = textBox2.Text;
File.WriteAllText(@"c:\\chat.csv", waarde1); */
I tried to create (I am a beginner) something. The above code writes the text in textBox2 to the csv file but it also deletes all the current.
What function can I use so that the data won't be removed?
Upvotes: 0
Views: 3037
Reputation: 1350
Do you mean to keep the text and add some new text?
File.AppendAllText("C:\\chat.csv", "newline");
Upvotes: 0