Hi all,
I'm trying to get my head around this but have tried a number of things with Sleep and Wait For, all of which failed. I think it's the recursion that gets in my way but perhaps am missing something else.
I want to get a folder's (and its subfolders') contents and display the folder currently being searched in a label. Without resumable subs, the UI of course isn't updating so the label's text doesn't change.
Any hints would be greatly appreciated!
I'm trying to get my head around this but have tried a number of things with Sleep and Wait For, all of which failed. I think it's the recursion that gets in my way but perhaps am missing something else.
I want to get a folder's (and its subfolders') contents and display the folder currently being searched in a label. Without resumable subs, the UI of course isn't updating so the label's text doesn't change.
Any hints would be greatly appreciated!
B4X:
Sub SomeSub
GetTheFolderContents("C:\somefolder")
End Sub
Sub GetTheFolderContents(fldr As String)
LabelFolder.Text = fldr ' Show this folder
For Each x In File.ListFiles(fldr)
If File.IsDirectory(fldr, x) Then
GetTheFolderContents(File.Combine(fldr, x)) ' Found a subfolder; process it
LabelFolder.Text = fldr ' Show this folder again after returning from a subfolder
Else
fList.Add(File.Combine(fldr, x)) ' Found a file; add it to list 'fList'
End If
Next
End Sub