B4J Question verify and copy file

lucdrb

Active Member
Licensed User
Longtime User
Hi

I want to verify if my db file exist in the DirData directory and if not copy it from the DirApp
my code:

If Not File.Exists(File.DirData,"qizine.rsd") Then
File.Copy(File.DirApp,"qizine.rsd", File.DirData,"qizine.rsd")
End If

on the 2 lines the compiler said: missing parameters
The #AdditionalJar: sqlite-jdbc-3.7.2 is in projects attribute

This code works well in B4A.
Any Help would be welcome

Thanks
Luc
 

LucaMs

Expert
Licensed User
Longtime User
Please, post the error msg, since there are no missing parameters in your File.Copy.
(I suppose that the AdditionalJar in your project is correct, with the right path and file name. The sqlite... jar must be in the additional libraries path)
 
Last edited:
Upvote 0

lucdrb

Active Member
Licensed User
Longtime User
You'll find hereafter the all text of the Main

#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#AdditionalJar: sqlite-jdbc-3.7.2
#End Region

Sub Process_Globals
Public db As SQL
Private fx As JFX
Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
LoadDatabase

End Sub

Sub LoadDatabase
If Not (File.Exists(File.DirData,"qizine.rsd")) Then
File.Copy(File.DirApp,"qizine.rsd", File.DirData,"qizine.rsd")
End If
db.InitializeSQLite(File.DirData,"qizine.rsd")
End Sub

and a screen copy of the error msg

Missing param.png

When I make a new B4J, It work until I saved it.

Thanks in advance

Luc
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The missing parameter is in File.DirData (see the tip of the command).

Probably you want to do as in B4A, copy from assets to application directory; then you should use:

B4X:
If Not(File.Exists(File.DirApp,"qizine.rsd")) Then

File.Copy(File.DirAssets, "qizine.rsd", File.DirApp, "qizine.rsd")

"qizine.rsd" must be added by Files Manager - Add Files, of course
 
Last edited:
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
B4X:
If File.Exists(File.DirApp,"qizine.rsd")=False Then
     'make copy
End If
 
Upvote 0

lucdrb

Active Member
Licensed User
Longtime User
Ok Thanks but:

The file.DirApp is read only, how should I use it to write into de DB (it's why I used the file.dirData directory)?


-To Giannimimaione thanks but I've already try it and the result is the same "missing parameter
Luc
 
Upvote 0

lucdrb

Active Member
Licensed User
Longtime User
I've found the missing parameter.
It's the (AppNameAsString) who as to be after the dirdata. Now with it everything is Ok:)

Luc
 
Upvote 0
Top