I am creating a small app for personal use that allows me to clean my lists of objects. I am using a variety of filters to get a finalized list in a multiline text box. When i am finished, I use the following code to copy to the textbox to the clipboard.
#region COPY BUTTON
private void button3_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBox_ListDestination.Text);
}
#endregion
What i would like to do now is add another button that allows me to save this same text to a .txt file using the SaveFileDialog. Can anyone help me with this? I am assuming I would use Streaming of some type, but I am out of my element here. Any help would be appreciated.
try
File.WriteAllText (TargetFilePath, textBox_ListDestination.Text);
For more information including sample code see MSDN .
If you want to obtain TargetFilePath
via a SaveFileDialog
see MSDN .
UPDATE
Sample code using SaveFileDialog
:
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
File.WriteAllText (saveFileDialog1.FileName, textBox_ListDestination.Text);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.