SaveFileDialog displaying only file with specific extension

Murhaf Sousli picture Murhaf Sousli · May 16, 2012 · Viewed 9.5k times · Source

I want to save an image which has two options (.Png or .Jpeg),so i need to display only files with Png and Jpeg format, like when we choose Save type as All Images it displays all kind of images in the dialog. so how would i do that?

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

Answer

spender picture spender · May 16, 2012

You'd be looking for a filter like this:

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

or optionally:

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