Just some follow-up for anyone who might be confused by or interested in this topic.
MacOS Ventura
Xojo 2023 v1.1
My test built app is FindRAA and it is in the Applications folder.
Christian writes:
The current working directory can change and doesn’t need to be the app folder.
Documentation says:
“Current working directory (depends on the location of the application). When run from Xojo, it is the path to Xojo. In a built app, it is the path to the built app.”
When I try this,
Var f As New FolderItem
f = SpecialFolder.CurrentWorkingDirectory.Parent
I just get Nil because f has no parent.
When I try this
Var f As New FolderItem
f = SpecialFolder.CurrentWorkingDirectory
The NativePath is: /
The Name is: Macintosh HD
So I do not understand the Documentation or it is wrong. I do not see how “it is the path to the built app.”
Tim writes that this should give you the Parent folder of the app:
Var f As New FolderItem ("")
In my testing on my machine this is true. I put the compiled application in the Applications folder. (I am having problems with the whole thing because some user reports a different outcome)
As Tim says, the documentation implies this in the discussion of Constructors under FolderItem.
The NativePath is: /Applications.
The Name is: Applications.
In my experiments this also works {you do not need the (“”)}, i.e. the default of a New FolderItem is the Parent folder of the application although I do not see this documented.
Var f As New FolderItem
The NativePath is: /Applications.
The Name is: Applications.
The documentation for App.ExecutableFile says:
“Returns a FolderItem for the actual executable Application even if it is in a bundle.”
Var f As New FolderItem
f = App.ExecutableFile.Parent
In my testing with an application called FindRAA sitting in the Applications folder this returned
The NativePath is: /Applications/FindRAA.app/Contents/MacOS
The Name is: MacOS.
This is not what I expected but whatever. Perhaps the Documentation could be clearer.
All of the above is perhaps irrelevant to my true life issue.
My actual problem is that my code works to make sure that the user has, as instructed, put my application in the Applications folder. I just get the Name using the Tim Streater technique and compare it with the string “Applications”. Most people do not seem to have a problem related to this, but a user from South Africa who is German has the application quit because it does not meet this criteria. His application folder seems to be “Programme” Is this something that non-English systems are likely to show? — some alternate name for the Applications folder. Perhaps I should not use the string “Applications” in my code but rather somehow get the name of the Applications folder on that particular machine. Perhaps on his machine, SpecialFolder.Applications would return as its Name — Programme.
Is anybody familiar with the names of the Application folder on non-English machines? I just assumed that it was “Applications” but perhaps there is some localization thing that changes this.