What’s the use of App.ExecutableFile?

I wasted hours and never was able to achieve my goal.

Only because App.ExecutableFile points to the application (.app.debug…).

What are-we doing with that ? Read or Write in the application ? What for ? I don’t get it.

I used App.ExecutableFile.Parent.Child(“My_image.png”) and the image appears magically !

I previously used App.ExecutableFile.Parent.Child(item) to access files placed beside my executable via a CopyFiles script.

This was for my Windows builds, however when I started compiling for Mac I realised you get a bundled app and the location it pointed to didn’t behave the same. So I started using the App Resources folder for my related files instead as I could access it the same way on both platforms.

1 Like

Well, by defining the executable as a folderitem, it allows you to access its folderitem properties (.Name, .CreationDate, etc.)–like you did with .Parent.

I used App.ExecutableFile.Parent.Child(“My_image.png”) and the image appears magically !

No “magic” there. That’s how it works. :slight_smile:

But I’m wondering why you’re not putting the file in the Resources folder. Also, in your related post about CopyFiles, you told us in advance not to advise you to simply drop the file into the project (where, by the way, you could set both “normal” and Retina versions.). But I suppose you have good reasons. :slight_smile:

The problem is not where I put my images (I put them by hand, Xojo does not do it with the version I use, and that is a debug session).

the problem is to have a FolderItem that Reference the Application inside the bundle. Who write something inside its own application (and how).

Even with System.DebugLog App.ExecutableFile.NativePath, it tooks me hours to understand how to use this FolderItem.

image

App.ExecutableFile points to Contents/MacOS/{application-name}.debug

If only it Reference the Contents folder !

With CopyFiles (when working), you can ask the files to be copied nearly where you want.

Instead of using executablefile, why don’t you use the excellent tpsf class from Tim Parnell which gives you direct access to the bundle.

2 Likes

I think of app.ExecutableFile more as a tool for reading, rather than writing. For instance, you might use SpecialFolder.ApplicationData.Child (app.ExecutableFile.Name) to create and access your app’s prefs folder. You could also use app.ExecutableFile.CreationDate if you wanted to display the build date in your “About” window.

2 Likes

Of course you can move up the parents to get to the bundle file to access the folder where the bundle resides. That’s where you could find files that are stored next to the bundle.

But is it a good place to store data? I think SpecialFolder.ApplicationData was intended for that purpose.

1 Like

CopyFiles does not works on Xojo 2021r2.1.

That is why I copy files there.

Now, if Xojo gave a Reference to the “Contents” folder of the Application Bundle, that discussion do not exists.

People use .Child() and would be happy.