I want just get Image(.JPG
,.PNG
,.Gif
) File from my OpenFileDialog
How can I get file extension from OpenFileDialog
?
Is it impossible?
There is a VBScript, the extension for that files would be VBS.
AddExtension Property (System.
From FileDialog. AddExtension Property: "Gets or sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension."
To filter only certain types of file use Filter Property
OpenFileDialog1.Filter = "Image Files (JPG,PNG,GIF)|*.JPG;*.PNG;*.GIF";
To get the file extension use the Path helper GetFileExtension
if (OpenFileDialog1.ShowDialog() == DialogResult.OK) string ext = Path.GetExtension(OpenFileDialog1.FileName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With