I wanted to know how to send all the entered user information from the textboxes on my form to one text file.

I was thinking I need to say MessageBox.Show("each textbox), but I don't think that is right.

All of this is is login information plus other user data so when it goes in a text file it will be sort of a database.

Please let me know if anyone can help.

Thank you!

Get all the textBoxes into an array, and read them (using Text property) into a StringBuilder class. Then write all to a text file:

Textbox[]tbs = { textBox1, textBox2, textBox3 }; // add all of them in here
StringBuilder sb = new StringBuilder();
foreach(TextBox tb in tbs)
     sb.AppendLine(tb.Text);

System.IO.File.WriteAllText(@"C:\myFile.txt", sb.ToString());

Get all the textBoxes into an array, and read them (using Text property) into a StringBuilder class. Then write all to a text file:

Textbox[]tbs = { textBox1, textBox2, textBox3 }; // add all of them in here
StringBuilder sb = new StringBuilder();
foreach(TextBox tb in tbs)
     sb.AppendLine(tb.Text);

System.IO.File.WriteAllText(@"C:\myFile.txt", sb.ToString());

Would I be able to add combo box information with this as well or is that something else?

Sure you can do, but you cannot addd comboBox control to TextBox array. But you can add its text additionally, like:

Textbox[]tbs = { textBox1, textBox2, textBox3 }; // add all of them in here
StringBuilder sb = new StringBuilder();
foreach(TextBox tb in tbs)
     sb.AppendLine(tb.Text);
//adding text from comboBox too:
sb.AppendLine(comboBox1.SelectedItem.ToString());

System.IO.File.WriteAllText(@"C:\myFile.txt", sb.ToString());

Sure you can do, but you cannot addd comboBox control to TextBox array. But you can add its text additionally, like:

Textbox[]tbs = { textBox1, textBox2, textBox3 }; // add all of them in here
StringBuilder sb = new StringBuilder();
foreach(TextBox tb in tbs)
     sb.AppendLine(tb.Text);
//adding text from comboBox too:
sb.AppendLine(comboBox1.SelectedItem.ToString());

System.IO.File.WriteAllText(@"C:\myFile.txt", sb.ToString());

Thank you so much for your help! :)

Anytime mate :)

how to make a read operation with this solution?

@Hatem_1: Please pose your question in a new thread, where you can refer to this one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.