2019r2 GetFolderItem

I do not understand what I should change to make it API2 compatible.
My code :

[code]Var name As String
Var f As FolderItem
Var fileName As String

fileName = GetAppFolder.nativePath + “VoiceFiles/” + “Master.dat”
f = GetFolderItem(fileName)

Analyze does show :
GetFolderItem = deprecated. You should use FolderItem.Constructor(path As String, pathMode As PathModes) instead

What should my code become ?



filename = getappfolder.child("VoiceFiles").child("master.dat").nativepath
f = New FolderItem(MyStringPathNative, FolderItem.PathModes.Native, FlagTarget)

FlagTarget is true by default and give you the Target if it’s an alias. If you write False then if MyStringPathNative is an alias then you get the alias.

f_Elt = GetFolderItem("") did gave me the folder on my application, I get the equivalent doing :

f_Elt = SpecialFolder.Resources #If TargetMacOS Then ' f_Elt est "MyApp.app/Contents/Resources" f_Elt = f_Elt.Parent.Parent.Parent #Else ' Windows ou Linux ' f_Elt est "MyApp Folder/Resources" f_Elt = f_Elt.Parent #EndIf
Is it ok or did I do something wrong ?

Please use the correct way of finding the resources folder. @Tim Parnell has a module for this, it uses (current) OS API to get the location of the Resources folder and others. This way when Apple change it, in theory your application should continue to work.

With the merger of macOS & iOS underway, I wouldn’t be surprised if future macOS apps adopt the iOS bundle structure which will break any hard coded functions to get to the Resources folder.

Could be true.