File Types?

Hi,
I have the following code, and I am trying to limit the type of file which can be selected to png and jpgs.

I have created a FileType set for the 2 types of images, but now not sure how to add it to my code below, as line 4 throws an error?

Any help appreciated.

Dim dialog As OpenDialog Dim file As FolderItem dialog = New OpenDialog dialog.Filter = FileTypes1 dialog.PromptText = "Please Select Image" file = dialog.ShowModalWithin(Self)

Thanks in advance.

FileTypes is a little messed up still.
The way your filter line should look is like this:

dlgOpen.Filter = FileTypes1.RAW.Extensions + FileTypes1.JPEG.Extensions

But whether or not it works depends on your last sacrifice to the gods.

The current workaround to make sure it works reliably is to define the filetype in code right before you use it.
feedback://showreport?report_id=45392

whats the name of your filetype?

dialog.Filter = FileTypes1.NameOf YourFiletype

or use the example from LR

[code]Dim jpegType As New FileType
jpegType.Name = “image/jpeg”
jpegType.MacType = “JPEG”
jpegType.MacCreator = “prvw”
jpegType.Extensions = “jpg;jpeg”

Dim pngType As New FileType
pngType.Name = “image/png”
pngType.MacType = "PNG "
pngType.MacCreator = “ogle”
pngType.Extensions = “png”

Dim f As FolderItem

//using the addition and conversion operators…
f = GetOpenFolderItem( jpegType + pngType )[/code]

Ok - this is what I now have so far:

[code]Dim jpegType As New FileType
jpegType.Name = “image/jpeg”
jpegType.MacType = “JPEG”
jpegType.MacCreator = “prvw”
jpegType.Extensions = “jpg;jpeg”

Dim pngType As New FileType
pngType.Name = “image/png”
pngType.MacType = "PNG "
pngType.MacCreator = “ogle”
pngType.Extensions = “png”

Dim dialog As OpenDialog
Dim file As FolderItem

dialog = New OpenDialog

dialog.PromptText = “Please Select Image”

file = dialog.ShowModalWithin(Self)[/code]

Where do I tell it to only allow the 2 file types?

[quote=304349:@Tim Parnell]The way your filter line should look is like this:

dlgOpen.Filter = FileTypes1.RAW.Extensions + FileTypes1.JPEG.Extensions

dialog.Filter = jpegType + pngType

Thanks Tim and Axel - I will try both :slight_smile:
Much appreciated.