B4J Question Dirasset

Tayfur

Well-Known Member
Licensed User
Longtime User
Hello;
I added some file in project (in . jar files)
I want to read with "dirasset".
I checked witih File.Exists(File.DirAssets,****
But it returns always FALSE;
why;

I cheked file; in jar file. its in jar.
I tried debug and release mode. Result is same.

I use diffrent sample from FORUM.
image shows, but cheking result is FALSE . (File.Exists(File.DirAssets,)o_Oo_O

I need first time dirasset folder.


B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    ShowSplashScreen
    Wait For Splash_Complete
    MainForm.Show
End Sub

Sub ShowSplashScreen
    Dim sp As Form
    sp.Initialize("sp", 600, 600)
    sp.SetFormStyle("TRANSPARENT")
    sp.BackColor = fx.Colors.Transparent
    Log(File.Exists(File.DirAssets, "B4R_512_512_transparent.png"))
    CSSUtils.SetBackgroundImage(sp.RootPane, File.DirAssets, "B4R_512_512_transparent.png")
    sp.Show
    sp.RootPane.Alpha = 0
    sp.RootPane.SetAlphaAnimated(500, 1)
    Wait For (sp.RootPane) sp_AnimationCompleted
    Sleep(3000)
    sp.RootPane.SetAlphaAnimated(1000, 0)
    Wait For (sp.RootPane) sp_AnimationCompleted
    sp.Close
    CallSubDelayed(Me, "Splash_Complete")
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 

Daestrum

Expert
Licensed User
Longtime User
I think @Tayfur is referring to the fact File.DirAssets only returns the string "AssetsDir" and not the actual folder path, so File.Exists always fails..

As a workaround
B4X:
Log(File.Exists(File.DirAssets, "B4R_512_512_transparent.png"))
can be written as
B4X:
Log(File.Exists("../files/", "B4R_512_512_transparent.png"))
 
Last edited:
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
I think @Tayfur is referring to the fact File.DirAssets only returns the string "AssetsDir" and not the actual folder path, so File.Exists always fails..

As a workaround
B4X:
Log(File.Exists(File.DirAssets, "B4R_512_512_transparent.png"))
can be written as
B4X:
Log(File.Exists("../files/", "B4R_512_512_transparent.png"))

Thank you for tips.
 
Upvote 0
Top