Android Question Copy some files from DirAssets to DirInternal

Douwe Siegersma

Member
Licensed User
Longtime User
I want to copy some files from DirAssets to DirInternal. Only files containing "old"'.
I always get a 'File not found' error.

B4X:
        Dim HL As List
        Dim F As String
        
        HL = File.ListFiles(File.DirAssets)
        For i = 0 To HL.Size-1
            F = HL.Get(i)
            If F.Contains("old") Then
                File.Copy(File.DirAssets,F,File.DirInternal,F)
            End If
        Next

And I only want to copy this files when the app is installed. How do I do that?
 

DonManfred

Expert
Licensed User
Longtime User
You can not use File.Listfiles on the Filesfolder.

YOU know what files are there. You also can create a textfiles with the filenames and search in this textfile.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Longtime User
Well...

I made a textfile containing all the files I want to copy (Dir /b >files.txt) and removed all the unwanted files.
Then copy this file to dir internal, fill the list (HL) and do the copy.
Only the first file in the list is copied. All the other files (150) generate a File Not Found error.
As suggested I do a log(F) before copying and I see no flaws in the filenames.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
As suggested I do a log(F) before copying and I see no flaws in the filenames.
You should start a new thread for a new issue.
Make sure not to use Uppercased filenames as they are not supportet in Assets too. All must be lowercased
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Well...

I made a textfile containing all the files I want to copy (Dir /b >files.txt) and removed all the unwanted files.
Then copy this file to dir internal, fill the list (HL) and do the copy.
Only the first file in the list is copied. All the other files (150) generate a File Not Found error.
As suggested I do a log(F) before copying and I see no flaws in the filenames.
Post that part.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Longtime User
B4X:
        Dim HL As List
        Dim F As String
        
        File.Copy(File.DirAssets,"files.txt",File.DirInternal,"files.txt")
        HL = File.ReadList(File.DirInternal,"files.txt")
        
        For i = 0 To HL.Size-1
            Try
                F = HL.Get(i)
                Log(F)
                File.Copy(File.DirAssets,F,File.DirInternal,F)
            Catch
            End Try
        Next
 
Upvote 0
Top