Nikola
Nikola

Reputation: 65

How to save text from text box in text file?

I have 3 text boxes and one button. On button click all text from text boxes should be written in text file (in one line). How can i do that?

Upvotes: 0

Views: 125

Answers (2)

dcg
dcg

Reputation: 4219

You can have all textboxes in a List<TextBox> and at the time of writing do:

list.ForEach(tb => file.Write(tb.Text));
file.WriteLine();

Upvotes: 0

Dmitrii Bychenko
Dmitrii Bychenko

Reputation: 186833

Direct implementation:

    File.WriteAllText(dest,
      tbID.Text + tbIme.Text + tbPrezime.Text);

Upvotes: 2

Related Questions