List saved files

volvomann

Active Member
Licensed User
Longtime User
Hallo.
Haow can i make a button with a code that listing all files in a directory
 

Mahares

Expert
Licensed User
Longtime User
Here it is Volvomann. Drive it:
B4X:
Dim btnList  as Button
Dim MyList As List
Dim MyFile As String
Dim i as Short

MyList.Initialize        'initialize list    
File.MakeDir(File.DirRootExternal,"Volvomann")

Sub btnList_click
    MyList=File.ListFiles("Volvomann")
    For i=0 To MyList.Size-1
           MyFile=MyList.Get(i)
           Msgbox(MyFile,"")
    Next
End Sub
 
Upvote 0

straybullet

Member
Licensed User
Longtime User
Is there an easy way to only files with a certain extension, for instance .txt?


Here it is Volvomann. Drive it:
B4X:
Dim btnList  as Button
Dim MyList As List
Dim MyFile As String
Dim i as Short

MyList.Initialize        'initialize list    
File.MakeDir(File.DirRootExternal,"Volvomann")

Sub btnList_click
    MyList=File.ListFiles("Volvomann")
    For i=0 To MyList.Size-1
           MyFile=MyList.Get(i)
           Msgbox(MyFile,"")
    Next
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here it is StrayBullet:

B4X:
Dim btnList  as Button
Dim MyList As List
Dim MyFile As String
Dim i as Short

MyList.Initialize        'initialize list    
File.MakeDir(File.DirRootExternal,"Volvomann")

Sub btnList_click
    MyList=File.ListFiles("Volvomann")
    For i=0 To MyList.Size-1
           MyFile=MyList.Get(i)
           If MyFile.EndsWith(".txt") Then
                   Msgbox(MyFile,"")
           End If
    Next
End Sub
 
Upvote 0
Top