How to apply file type to a file ?

I have an old project which creates several customized file types. These are of cause defined in the File Type set. When I first create a file with the SaveAsDialog, you are able to specify the file type in the setup of the dialog before it is presented. Fine - the file becomes the decided type and gets its icon.

  1. But when you want to create a file without using a dialog (f.ex. a preference file), how can I specify the file type? It seems that there is no parameters for defining that without using a dialog?
  2. When I later open the file for writing with a TextOutputStream, the type of the file becomes text and the creator changes to ‘text’ and the icon changes accordingly.

Ealier I was able to set MacType and creator for the folder item after closing the stream, but now the MacType is depricated and I do not find a substitution for changing the file type back to what it originally was.

Is there a workaround or did I get the procedure of working with custom files totally wrong?

Because you used TextOutputStream to create it (TextInputStream to read it).

Use BinaryStream.

MacType has been replaced by the UTI
And when you set up the UTI you specify what extensions the files of a given type use
And then you just create files with those extensions

Be aware that you can make the extensions about as long you’d like

Xojo projects have 3 different ones

and then there are all kinds of others for the text format