hi,
i'm searching for a faster method to retrieve the first image in a folder.
Any suggestion?
now i have this code but is very slow:
i'm searching for a faster method to retrieve the first image in a folder.
Any suggestion?
now i have this code but is very slow:
B4X:
Sub searchFirstImageInFolder(path1 As String) As String
Dim lstFilter As List
lstFilter.Initialize
lstFilter.AddAll(Array As String(".jpg", ".gif", ".png", ".jpeg" ))
Dim fileList As List
fileList.Initialize
fileList = File.listfiles(path1) '<<--- load files from folder path1
Dim tmpFileName As String
tmpFileName=""
For i = 0 To fileList.Size - 1
tmpFileName =fileList.Get(i)
For f = 0 To lstFilter.Size - 1
If tmpFileName.ToLowerCase.EndsWith(lstFilter.Get(f)) Then
i=fileList.Size - 1 '<<--- FOUND! then force exit from 1' for
Exit
Else
tmpFileName=""
End If
Next
Next
Return tmpFileName '--- return 1' image in folder
End Sub