Filter isn't filtering

Hi All.

This is driving me crazy… a short drive, granted, but still.

I am trying to filter certain file types in a folder I have. With a button I deploy this code:

Var dlg As New OpenDialog
dlg.Title = “Select an PNG image file”
dlg.Filter = ImageFiles.myImages.Extensions // defined in the File Types Editor…

Var f As FolderItem = dlg.ShowModal
If f <> Nil Then
MessageBox ("The file name is : "+f.name)
Else
// user cancelled
End If

However, I get all file types… png, wmv, bmp… everything.

In my ImageFiles filter, I have in the extensions field:

image/png

but I get everything. I am probably doing something silly, but I can’t see it.

Regards

Do you still have to declare the filter every time???

dim theDialog as new SaveFileDialog
theDialog.PromptText = kSaveArchive
theDialog.SuggestedFileName = kArchive + "." + FileTypes.DB.Extensions
Dim DBType As New FileType
dbType.Name = "vdb"
dbType.Extensions = "vdb"
theDialog.Filter = DBType
dim theResult as FolderItem= theDialog.ShowModal

Hi Beatrix.

I got this to work for me… which appears to be pretty much the same as yours, though not as classy…

var f as New FolderItem

Var jpegType As New FileType
jpegType.Name = “image/jpeg”
jpegType.Extensions = “jpg;jpeg”

Var pngType As New FileType
pngType.Name = “image/png”
pngType.Extensions = “png”

// Use the addition and conversion operators to combine the file types
f= FolderItem.ShowOpenFileDialog(jpegType)

If f <> Nil Then
MessageBox ("The file name is : "+f.name)
Else
// user cancelled
End If

Hopefully this will help someone who comes after me… or ME… if I forget… again…

Regards

Extensions should be set to .png and mime-type should be set to image/png.