FileType only for open dialogs but not the app itself

Hi,

I want to allow the user to edit files using an open dialog, in a specific area inside the app. It doesn’t make sense, in this context, to allow the files to be directly open in the app class (using double-clic or drag&drop to the app’s icon). In other words, I have to allow this file type in an open dialog but don’t want LaunchServices to register the file type with my app.

I’d like a better solution than build the app, edit the info.plist file to remove the file type, and only then launch the app. I’m not even sure the open dialog would still recognise the file type, then.

How would this be achieved?

I do not know if this is what you want:


jpegType.Extensions = "jpg;jpeg"

Var pngType As New FileType
pngType.Name = "image/png"
pngType.Extensions = ".png"
2 Likes

Ah yes, I forgot the file type in code.
Thank you!

You’re Welcome !

@Arnaud_N

You can control the registration by changing your app’s “role” for each file type.

1 Like

Thanks. More complex than the file type in code, but certainly gives finer control.
For now, Emile’s answer works like a charm.

2 Likes