iOS Question get file size of a file in file.dirdocuments

tufanv

Expert
Licensed User
Longtime User
Hello,

How can I get the size of a file in file.dirdocuments ?

Thanks
 

MarcoRome

Expert
Licensed User
Longtime User
B4X:
FormatFileSize(File.Size(....))

Sub FormatFileSize(Bytes As Float) As String
    Private Unit() As String = Array As String(" Byte", " Kb", " Mb", " Gb", " Tb", " Pb", " Eb", " Zb", " Yb")
    If Bytes = 0 Then                   
        Return "0 Bytes"
    Else     
        Private Po, Si As Double
        Private I As Int       
        Bytes = Abs(Bytes)                           
        I = Floor(Logarithm(Bytes, 1024))
        Po = Power(1024, I)
        Si = Bytes / Po     
        Return NumberFormat(Si, 1, 1) & Unit(I)     
    End If
End Sub
 
Upvote 0
Top