Here I am going to demonstrate how to use SaveFileDialog in C#.Net.
Example
Creating stream for writing file
Stream str;
//creating object of SaveFileDialog
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
//creating filter to saveFileDialog
saveFileDialog1.Filter = "Text File|*.txt";
//checking whether saved button is pressed or not.
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((str = saveFileDialog1.OpenFile()) != null)
{
//creating stream writer.
StreamWriter wText = new StreamWriter(str);
//writing text to file.
wText.Write(" your text");
//closing stream.
str.Close();
}
MessageBox.Show("FileSaved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
Manish Kumar
16-Jun-2017Your words increase my knowledge for sure. Thanks