Sub FindFolder(myPath As String, subfolder As String) As String
Dim fl As List
Dim i As Int
Dim p,f,r,dummy As String
dummy=File.DirRootExternal 'Get sdcard Permission
Log (mypath)
fl.Initialize
Try
'Listfiles throws Exception on some folders
If mypath = "" Then
fl = File.ListFiles("/")
Else
fl = File.ListFiles(myPath)
End If
Catch
Return ""
End Try
'Listfiles returns null for some system folders
If fl.IsInitialized = False Then Return ""
For i = 0 To fl.size-1
p = mypath
f = fl.Get(i)
Select p 'ignore some system folders
Case "/dev"
Case "/proc"
Case "/sys"
Case "/system"
Case Else
If File.IsDirectory(p,f) Then
If f = subfolder Then Return p & "/" & f '<--- success
If File.IsDirectory(p, f) Then
p = p & "/" & f
p = FindFolder(p, subfolder) '<---recursive search
If p <> "" Then Return p '<---success
End If
End If
End Select
Next
Return ""
End Sub