B4J Question B4J: Using for each with files?

LWGShane

Well-Known Member
Licensed User
Longtime User
I'm almost done with the next version of my Launcher app, and would like to know if it's possible to use a "For Each" statement to copy files.
 

Cableguy

Expert
Licensed User
Longtime User
I would say yes, but it all depends on what exactly you want to do!

ie: You can populate a list from the DirectoryChooser with the files under a chosen directory, and go through that list to only copy upon criteria
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Something like this ?
B4X:
    Dim dir As String = "c:/b4j problems"         ' source
    Dim dir1 As String = "C:/b4j problems/copy" 'dest
    File.MakeDir("C:/b4j problems","copy")
    For Each f As String In File.ListFiles(dir)
        If File.IsDirectory(dir,f) Then
            Log("<dir> " & f)  ' don't copy directories
        Else
            File.Copy(dir,f,dir1,f)
            Log("copied "& f & " to " & dir1)
        End If
    Next
 
Upvote 0

LWGShane

Well-Known Member
Licensed User
Longtime User
@Cableguy & @Daestrum - Thanks for your help! My launcher can now use private versions of ABMaterial provided by the user :)
 
Upvote 0
Top