If I have subfolders within my resources folder, is there a way to specify the whole path, or do I have to use “child” for each subfolder.
e.g. I’d LIKE to be able to do:
Dim f as FolderItem = SpecialFolder.Resources("MacOS/MyHelper.app")
Dim f as FolderItem = SpecialFolder.Resources("Windows\\MyHelper.exe")
As opposed to
Dim f As FolderItem = SpecialFolder.Resources.Child("MacOS").Child("MyHelper.app")
The reason for this is I’d like to use a Dynamic constant for the path and filename if possible. (Maybe it’s not?)
Dim f As FolderItem = New FolderItem(Specialfolder.Resource.nativepath + "MacOS/MyHelper.app")
This is untested, but should work.
a) Use TPSF (https://github.com/devtimi/TPSF).
b) Always use child and check the folders for Nil and if they exist.
c) Helper apps should be in Contents/Library/Helpers.
a. if you are a hobbist, do not do that, else, why recreate the wheel ?
b. Using a path (instead of a single directory name) without testing it is a bad idea (hobbyist user ?).
c. Yes, Sundays programmers.
[quote=471488:@Andy Broughton]Why TPSF?
I created TPSF long ago before
SpecialFolder.Resources existed. It uses declares to get the paths on macOS, and has been time tested to get the library / resources on Windows correctly across older IDE versions. If you use the new API you won’t need TPSF to get the Resources folder.
not doing so can lead to exceptions when there are missing directories in the path to the final item
using child lets you detect this and even react to it - perhaps by creating the missing dirs along the way IF you have permissions etc (ie/ you cannot and should not try to create new dirs inside an app bundle on macOS)
however, there can be situations where you just need to know IF the item exist and any failure is an indication that it does not
catch the exception and carry on knowing that the item you sought doesnt exist