B4J Code Snippet listing File.DirAssets

Normally if you try and do
Code: Copy
Log(File.ListFiles(File.DirAssets))

you get message cant list DirAssets

Code: Copy
Dim currentFilesFolder = File.DirApp.Replace("Objects","Files")
Log(File.ListFiles(currentFilesFolder))

Seems to work fine (also for saving to the directory too in debug)

Probably a good reason not to do it though.
 
Last edited:
A solution that will work in all modes:

1. Add to Main or B4XMainPage:
Code: Copy
#CustomBuildAction: folders ready, %WINDIR%\System32\cmd.exe, /c dir /b ..\Files\ > ..\Files\dir.txt

It will create a file named dir.txt in the Files folder, during compilation, with the list of files.

2. Click on the Sync button in the Files tab to add this file. Only required once.

3. To get the files at runtime:
Code: Copy
For Each f As String In File.ReadList(File.DirAssets, "dir.txt")
    Log(f)
Next
 
Unfortunately I need a live list of files in assets while using pybridge so I can hot swap python code without restarting compile/run each time.
 
Unfortunately I need a live list of files in assets while using pybridge so I can hot swap python code without restarting compile/run each time.
How about put your files inside Objects folder?
 
Back
Top