SaveFileDialog only displays a file with a specific extension

I want to save an image with two parameters (.Png or .Jpeg), so I only need to display files with the Png and Jpeg format , for example, when we select Save type as All images displays all images in a dialog box. so how can i do this?

using(SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
     saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyPictures);
     saveFileDialog1.Filter = "Images (*.Png + Jpeg)|*.Png + *.Jpeg";
}
+5
source share
1 answer

You would be looking for a filter like this:

"Images (*.png,*.jpeg)|*.png;*.jpeg";

or optionally:

"Images (*.png,*.jpeg)|*.png;*.jpeg|All files (*.*)|*.*"
+8
source

All Articles