SaveFileDialog displaying only file with specific extension
Asked Answered
G

1

5

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";
}
Grunion answered 16/5, 2012 at 2:8 Comment(4)
Possible dup. I'm pretty sure I've seen this here before...Gerigerianna
Sad to see a downvote for no obvious reason.Concordia
@jdmcnair this's not duplicate ... but you haven't even read the question, the answer in your link is not what i was looking for.Grunion
@jdmcnair if you check Spender answer and your link part "I figure it out, this is how you do it: " you will see the different, i asked a simple question of how to show many files extensions in one type like *.bmp;*.jpeg;*.png" not many files extensions in multi types. that's the different.Grunion
C
8

You'd be looking for a filter like this:

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

or optionally:

"Images (*.png,*.jpeg)|*.png;*.jpeg|All files (*.*)|*.*"
Concordia answered 16/5, 2012 at 2:13 Comment(1)
the second line is wrong and will rise an exception! the correct form is: "Images (*.png,*.jpeg)|*.png|*.jpeg|All files (*.*)|*.*"Histrionism

© 2022 - 2024 — McMap. All rights reserved.