I'm trying to save the contents of a textbox to a text file using Visual C#. I use the following code:
private void savelog_Click(object sender, EventArgs e)
{
if (folderBrowserDialog3save.ShowDialog() == DialogResult.OK)
{
// create a writer and open the file
TextWriter tw = new StreamWriter(folderBrowserDialog3save.SelectedPath + "logfile1.txt");
// write a line of text to the file
tw.WriteLine(logfiletextbox);
// close the stream
tw.Close();
MessageBox.Show("Saved to " + folderBrowserDialog3save.SelectedPath + "\\logfile.txt", "Saved Log File", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
but I only get the following line of text in the textfile:
System.Windows.Forms.TextBox, Text:
Followed by only a short portion of what was actually in the textbox, ended with '...'. Why doesn't it write the entire contents of the textbox?