Android Question Get Size of Huge Directory

PoleStar

Member
Licensed User
Longtime User
Hi any one
I geting the Directory size trough this code:
B4X:
Sub CalcSize(Folder As String, recursive As Boolean) As Long
Dim size As Long
For Each f As String In File.ListFiles(Folder)
If recursive Then
if File.IsDirectory(Folder, f) Then
size = size + CalcSize(File.Combine(Folder, f),recursive)
End If
End If
size = size + File.Size(Folder, f)
Next
Return size
End Sub

But when a large number of files in the folder(directory), my application hangs for long time and finaly application closes.

Way to solve this problem?
Thanks a lot :)
 
Top