Hi all.
For my app I need to know the number of subfolder levels that a given folder has. Not the number of folders and subfolders, but the 'depth' of the folders structure. I've tried with something like
...but doesn't work, because 'level' increases with every folder that the code finds.
I've been trying for a long time, but haven't found the way, and looked for it in the forum, but no luck.
Any ideas?
For my app I need to know the number of subfolder levels that a given folder has. Not the number of folders and subfolders, but the 'depth' of the folders structure. I've tried with something like
B4X:
Sub CountDirLevels(Folder As String) As Int
Dim level As Int = 0
For Each f As String In File.ListFiles(Folder)
If File.IsDirectory(Folder, f) Then
level = level + 1
CountDirLevels(File.Combine(Folder, f))
End If
Next
Return level
End Sub
...but doesn't work, because 'level' increases with every folder that the code finds.
I've been trying for a long time, but haven't found the way, and looked for it in the forum, but no luck.
Any ideas?