I am trying to distribute a simple application to friends/family. Mac only. Free. Desktop app.
No app store, no complicated installer.
What I want to do is just to provide a zip file. The user would unzip the file wherever they wanted on their machine and the application (MyApp) that I have created would be there as well as some support files that I have created all sitting in a folder called (MyAppFolder).
Now I want to have a file with a specific name (MyPicture.png, for example) somewhere that the user would create. It would be a .png file and the user would be told to put it in a given location. Inside the MyAppFolder at the same level as the application itself seems like a natural place and one that is easy to explain. The application itself would look for a file of the agreed-upon name (MyPicture.png in this example) and things would be cool.
Since the user could unzip the file that I provided in any location, I would need to figure out the path to MyAppFolder so I could reference the MyPicture.png. I would know that its path was …/MyAppFolder/MyPicture.png.
If I knew the path to the folder MyAppFolder, that would be easy to figure out. So I look to see if there is a SpecialFolder that refers to the Folder that contains MyApp but I cannot find it. That seems bizarre to me because it seems natural to me that this would be a useful location to know.
It seems that when I build an app (like MyApp) I am actually creating a “Package” and the executable is in the depths of that Package. It looks like … MyAppFolder/MyApp.app/Contents/MacOS/MyApp
Now if this were universally a true pattern then I can find my way to the MyAppFolder is a roundabout way
Var h As FolderItem h = app.ExecutableFile Var folderOfApp As FolderItem folderOfApp = h.Parent.Parent.Parent.Parent Var pathFolderOfApp As String pathFolderOfApp = folderOfApp.NativePath
But this makes me nervous. It seems very kludgy. More to the point, I wonder whether my assumptions are “wrong” in some way or under some circumstances that I am not anticipating. I am finding the FolderItem reference to the executable and then noticing a pattern that allows me to move up a certain number of folders and then retrieve a path of MyAppFolder. It seems like I am “fighting” something. That Xojo does not want or cannot provide an easy way to get to the path of the folder that contains the application.
I am doing something that is frowned upon? Is there a better way to meet the needs of having the user be told a “simple” place to put a file? It seems so natural to me that that place would be in the same folder as the application itself.