Android Code Snippet List Folders or ListFiles

Discussion in 'Code Snippets' started by hibrid0, Jun 19, 2015.

  1. hibrid0

    hibrid0 Active Member Licensed User

    Hi I shared a simple code to get a list of folders or Files without folders

    Get List Folders

    Code:
    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
    Code:
    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice