Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple file extensions in OpenFileDialog

How can I use multiple file extensions within one group using OpenFileDialog? I have Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg|PNG|*.png|TIFF|*.tiff" and I want to create groups so JPG are *.jpg and *.jpeg, TIFF are *.tif and *.tiff and also 'All graphic types'? How can I do that?

like image 259
Ichibann Avatar asked Jan 17 '11 07:01

Ichibann


People also ask

How do I select multiple files in OpenFileDialog in VB net?

In order to select a Multiple Files, the Multiselect property of the OpenFileDialog Box needs to be set to True. The Path of the selected File is available in the FileName property of the OpenFileDialog Box. The Name and Path of the selected Files are displayed in the Windows Forms MessageBox.

How do I get the selected file from OpenFileDialog box?

OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System. IO.


2 Answers

Try:

Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff" 

Then do another round of copy/paste of all the extensions (joined together with ; as above) for "All graphics types":

Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff|"        + "All Graphics Types|*.bmp;*.jpg;*.jpeg;*.png;*.tif;*.tiff" 
like image 117
user541686 Avatar answered Oct 06 '22 03:10

user541686


This is from MSDN sample:

(*.bmp, *.jpg)|*.bmp;*.jpg 

So for your case

openFileDialog1.Filter = "JPG (*.jpg,*.jpeg)|*.jpg;*.jpeg|TIFF (*.tif,*.tiff)|*.tif;*.tiff" 
like image 23
Saeed Amiri Avatar answered Oct 06 '22 02:10

Saeed Amiri