Android Code Snippet CalcSize - Get size of a folder

Author: @Erel See here.
I´ve changed it a bit and share it here in the Code-Snippets

Description: Get the total size of an folder.
You can use it recursive or not

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

Tags: Foldersize, Filesize, Recursive

Dependencies: none
 

DonManfred

Expert
Licensed User
Longtime User
Feel free to copy the sub to your codebase and rename the sub as you want...
 
Top