C# Savefiledialog Filter Code Example


Example: save dialog filter c#


SaveFileDialog textDialog;
public Page()
{
InitializeComponent();
textDialog = new SaveFileDialog();
textDialog.Filter = "Text Files | *.txt";
textDialog.DefaultExt = "txt";
}

private void button1_Click(object sender, RoutedEventArgs e)
{
bool? result = textDialog.ShowDialog();
if (result == true)
{
System.IO.Stream fileStream = textDialog.OpenFile();
System.IO.StreamWriter sw = new System.IO.StreamWriter(fileStream);
sw.WriteLine("Writing some text in the file.");
sw.Flush();
sw.Close();
}
}

Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy