Android Code Snippet List Folders or ListFiles

Status
Not open for further replies.

hibrid0

Active Member
Licensed User
Hi I shared a simple code to get a list of folders or Files without folders

Get List Folders

B4X:
Sub ListFolders(dir As String)
Dim list_files As List
Dim lista_folders As List
lista_folders.Initialize
    list_files=File.ListFiles(dir)
    For i= 0 To list_files.Size -1
        If File.IsDirectory(dir, list_files.Get(i))=True Then
            lista_folders.Add(list_files.Get(i))
        End If
    Next
Return lista_folders
End Sub
Get List Files
B4X:
Sub ListFiles(dir As String)
Dim list_files As List
Dim lista_folders As List
lista_folders.Initialize
    list_files=File.ListFiles(dir)
    For i= 0 To list_files.Size -1
        If File.IsDirectory(dir, list_files.Get(i))=false Then
            lista_folders.Add(list_files.Get(i))
        End If
    Next
Return lista_folders
End Sub
 

Urishev

Member
Licensed User
In the old version 5.5 it worked. In version 8.8 does not work. "(List) Not initialized". Why?
 

DonManfred

Expert
Licensed User
1. This is not the correct place for your question. ALWAYS create a new thread for any Question you have.
2. Posting the same question AGAIN (2 TIMES) does not help at all! BE MORE PATIENT. But start with creating a new thread for your quetions. Make sure to post all relevant infos.
3. The code is just working fine here. I have B4A 9. Running on a Samsung Note 8 with Android 9.
 
Status
Not open for further replies.
Top