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

C Perror Example

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"