B4J Question Can't find HTM file when Packaged to Executable

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Another one. When I compile in release mode the helpfile.htm is happily displayed in the browser.
When the jar is "Packaged" with the B4JPackager and the sub/file is called Firefox responds with:
"Firefox can't find the file at /C:/Program Files/Antenna Bearing Tool/app/helpfile.htm."

When I use the File Explorer the app dir contents show only the jar and a cfg file. When I use a button on the App that opens a sub directory of /app/ and go up a level, file explorer shows the jar, cfg, the sub dir and helpfile.htm.

The htm file is there but in hidding. It may be some windows 10 trick???

Any idea's?

Regards Roger
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Yes, I copy the htm file from DirAssets at AppStart.

B4X:
If File.Exists(File.DirApp, "helpfile.htm") = False Then File.Copy(File.DirAssets, "helpfile.htm", File.DirApp, "helpfile.htm")

The Sub Help_action is called by the use. Plenty of time for the copy to complete.

Regards Roger
 
Last edited:
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel

Changing to File.DirData produces the warning "Cannot assign void value". Does this mean I can't test to see if the file exists?

B4X:
If File.Exists(File.DirData, "helpfile.htm") = False Then File.Copy(File.DirAssets, "helpfile.htm", File.DirApp, "helpfile.htm")

If I only use the following it works OK. [Release mode only so far]

B4X:
File.Copy(File.DirAssets, "helpfile.htm", File.DirApp, "helpfile.htm")

Roger
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are not using it correctly. It is a method that expects a single parameter:

SS-2016-01-03_09.57.36.png


The best way is to declare a process global variable:
B4X:
Sub Process_Globals
   Public DataFolder As String
End Sub

'in AppStart
DataFolder = File.DirData("YourAppName")
 
Upvote 0
Top