B4J Question ListFiles(DirApp) returns only the Jar file

wonder

Expert
Licensed User
Longtime User
Hello hello!

Why isn't "skull.obj" being listed?

Code:
B4X:
For Each entry As String In File.ListFiles(File.DirApp)
    Log(entry)
Next
If File.Exists(File.DirApp, "skull.obj") Then Log("The file does exist!")

Output:
B4X:
'Program started.
'arena.jar
'The file does exist!

PS: I know the read-only limitations of using DirApp under Windows. That's not a problem for me, I just want to read the file.
 
Last edited:

wonder

Expert
Licensed User
Longtime User
In the same folder as the .jar file.

B4X:
If File.Exists(File.DirApp, "skull.obj") Then Log("The file does exist!")

As you can see, File.Exists "detects" the file, but File.ListFiles does not...
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
In most cases it will be the jar folder as the user double clicks on the jar. However if you run it from the command line and you run it from a different folder then it will be a different folder. It should behave this way on all OSs.

The behavior is the same from either double-click or command line.

Can you reproduce it? You can use a dummy obj file.
 
Last edited:
Upvote 0

wonder

Expert
Licensed User
Longtime User
I'm not able to update B4J right now, but changing "For Each..." to "For i = 0..." resolved the problem.

B4X:
For i = 0 To (files.Size - 1)
    Log(files.Get(i))      
Next

Output:
B4X:
Program started.
'arena.jar
'bin
'ObfuscatorMap.txt
'skull.obj
'src
 
Upvote 0
Top