title: Visual C# - Write contents of a textbox to a .txt file
body: <p>I'm trying to save the contents of a textbox to a text file using Visual C#. I use the following code:</p>
  
  <pre><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);
          }
      }
  </code></pre>
  
  <p>but I only get the following line of text in the textfile:</p>
  
  <pre><code>System.Windows.Forms.TextBox, Text: 
  </code></pre>
  
  <p>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?</p>