Drama with FileType

So what is going on with FileType…

Nothing is consistent there on what works between the platforms…

This code works on Windows and Mac but not Linux

var ftype as FileType = new FileType()
ftype.Extensions = ".png"
ftype.Name = "PNG"

var f as FolderItem = FolderItem.ShowOpenFileDialog(ftype)

This code works on Windows, Mac and Linux

var ftype as FileType = new FileType()
ftype.Extensions = "png"
ftype.Name = "PNG"

var f as FolderItem = FolderItem.ShowOpenFileDialog(ftype)

This code works on Windows, and Linux but not on Mac

var ftype as FileType = new FileType()
ftype.Extensions = "*"
ftype.Name = "Any"

var f as FolderItem = FolderItem.ShowOpenFileDialog(ftype)

This code works on Windows but not on Linux or Mac

var ftype as FileType = new FileType()
ftype.Extensions = ".*"
ftype.Name = "Any"

var f as FolderItem = FolderItem.ShowOpenFileDialog(ftype)

This code works on Windows but not on Mac (dontk now on Linux)

var ftype as FileType = new FileType()
ftype.Extensions = "*.*"
ftype.Name = "Any"

var f as FolderItem = FolderItem.ShowOpenFileDialog(ftype)

So at this point I have no idea how any is supposed to work on macOS since no combination is working there. But wait… if not doing it in FileType then it happens to work on Mac.

Works on Mac

var f as FolderItem = FolderItem.ShowOpenFileDialog("*.*")

How is this supposed to work is this not unit tested across platforms ? It is very frustrating battling this.

1 Like

This seems to work on macOS also, no idea on the other platforms

var ftype as FileType = new FileType()
ftype.Extensions = ""
ftype.Name = "Any"

have you test if it works better if you add/insert a “File Type Group” to your project?
and for the Dialog FileTypeGroup1.All

Works pretty much same there since that is only designer on same classes.

But you need to there also be really careful since some things work on some platforms but not on others.

That is the whole point of the story.

Class really should define one way, and make sure any other way does not work on any platform. Since if user has it working on one platform then user will blindly think it works on all platforms.

1 Like

agree, its something for the feedback tool in hope somebody cares.

Daft question: when you say ‘doesnt work’, does it show any PNG files at all on Linux?
because Linux is case sensitive… do your PNG files ending with PNG or png ?

All the files were lower case. And besides removing the dot makes it work on Linux so obviously not case sensitive issue.

I am basically guessing it should be always file ending with no dot or * in-front and for “All” it should be empty string. And then it probably works on all platforms.

This needs to be

  • Documented
  • Class should throw exception or things not work on any platforms if anything else is fed to it.
1 Like

if it not work at all platforms then it is currently wrong documented with
.Extensions = “.png”
and
.Extensions = “jpg;jpeg”

https://documentation.xojo.com/api/files/filetype.html#filetype-extensions

1 Like

Yes, first part of their example is probably correct (with the jpg) while the later one with the png is not.