I have text files like MyApp.Txt in my app's Files directory that need manual editing from time to time with a text editor. If I edit the text text file(s) and run the B4J app, the app is still using the cached file(s) in c:\Users\...\AppData\Pgmx\MyFile.Txt. I waste a lot of time debugging my app only to realize later it is still using the old file on C:.
Is there an easy way to get B4J to erase the files in c:\Users\...\AppData\PgmX\*.* prior to running app and always copy the files from D:\B4X_Apps\B4X_My_Apps\PgmX\Files?
I thought "Tools > Clean Project" would do it, but it doesn't.
Dim xui As XUI
Sub AppStart (Form1 As Form, Args() As String)
xui.SetDataFolder("yourApp")
For Each f As String In File.ListFiles(xui.DefaultFolder & "\Pgmx")
Dim k As String = f
File.Delete(xui.DefaultFolder & "\Pgmx", k)
Next
For Each fa As String In File.ListFiles("D:\B4X_Apps\B4X_My_Apps\PgmX")
Dim ka As String = fa
File.Copy("D:\B4X_Apps\B4X_My_Apps\PgmX", ka, xui.DefaultFolder & "\Pgmx", ka)
Next
'Rest of Code
'.....
'.....
End Sub
Are you suggesting I write code when my program terminates to delete the old text files from c:\Users\...\AppData\PgmX\*.*? That way the files will be automatically copied from the Files directory? Currently I have a batch file to move the files from the Files directory to the c:\Users\...\AppData\PgmX\ directory which is a bit cumbersome because I have to remember to execute it when I modify the text file or the Sqlite database in the Files directory.
Dim xui As XUI
Sub AppStart (Form1 As Form, Args() As String)
xui.SetDataFolder("yourApp")
For Each f As String In File.ListFiles(xui.DefaultFolder & "\Pgmx")
Dim k As String = f
File.Delete(xui.DefaultFolder & "\Pgmx", k)
Next
For Each fa As String In File.ListFiles("D:\B4X_Apps\B4X_My_Apps\PgmX")
Dim ka As String = fa
File.Copy("D:\B4X_Apps\B4X_My_Apps\PgmX", ka, xui.DefaultFolder & "\Pgmx", ka)
Next
'Rest of Code
'.....
'.....
End Sub
I don't think I can delete the files from the AppStart directory, because if the files are missing from the c:\Users\...\AppData\Pgmx\ directory when I compile the app, B4J will automatically copy the updated text files from the Files directory to this c:\Users\...\AppData\Pgmx\ directory and I would be deleting these newly copied files. Or did I miss something?
Ok, what am I misconstruing here. The Files directory is statically embedded into the jar file created when compiling your app. If you update any files in the Files directory, then you have to recompile the app in order for the app to use the files