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
This can be used to prompt for any file name.
private void savelog_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "*.txt|*.txt"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { File.WriteAllText(dlg.FileName, textBoxLog.Text); } }