B4J Question [RESOLVED] File.DirApp on package File MAC

MarcoRome

Expert
Licensed User
Longtime User
Hi All.
Houston we have a problem 🥴
As explained in this post.

When the package is packaged using Macsigner and becomes a single file, the File.DirApp directory is no longer usable.
Now with "temporary" files such as PDFs that are loaded, Excel files that are saved can be moved to the File.DirTemp folder and everything works properly.
But if a file must be persistent, such as a db, which directory can it be moved to ?

Looking at the following documentation, I don't think there are any valid alternatives.

File.DirAssets - The assets folder holds the files that were added to the Files tab. This is a virtual read-only folder. When you compile your program in Release mode the files are packaged inside the Jar files.

File.DirTemp - A temporary folder.

File.DirApp - The program folder. This is the path to the jar file. Note that on Windows it might be read-only (if the program is installed in Program Files).

File.DirData - A folder suitable for writing files. On non-Windows it is the same as File.DirApp. On Windows it points to the user data folder

Any suggestion ?
Thank you
Marco
 
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
More information.
I did some tests.
if you use the following code

B4X:
Dim tempDir As String
    tempDir = File.Combine(File.DirApp, "TempFolder")
   
    Log(File.DirApp)
  

    ' Crea la directory di appoggio se non esiste già
    If File.Exists(tempDir, "") = False Then
        File.MakeDir(tempDir, "")
        fx.Msgbox(MainForm, tempDir,"")
    Else
        fx.Msgbox(MainForm, tempDir,"**ESISTE**")
    End If

using run.command you have the following result (correct and folder is created )

WhatsApp Image 2023-12-14 at 17.10.35.jpg


using package file you have the following result and no folder is created

WhatsApp Image 2023-12-14 at 17.10.57.jpg
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Upvote 0
Top