Описание функции


ShortFileSize

Получает округлённый размер файла/папки/диска в краткой форме с одной из приставкок Тб, Гб, Мб, кб

ShortFileSize(Bytes.q)

Параметры

Bytes.q Размер в байтах

Возвращаемое значение

Успех:Возвращает строку, размер данных

Пример

; AZJIO
Procedure.s ShortFileSize(Bytes.q)
    Protected res.s
    Select Bytes
        Case 10995116277760 To 109951162777600 ; 10 - 100 TB
            res = StrD(Round(Bytes / 109951162777.6, #PB_Round_Nearest)/10.0) + " TB"
        Case 1000000000000 To 10995116277759 ; 1000 GB - 10 TB
            res = StrD(Round(Bytes / 10995116277.76, #PB_Round_Nearest)/100.0) + " TB"
        Case 107374182400 To 999999999999 ; 100 - 999 GB
            res = StrD(Round(Bytes / 1073741824, #PB_Round_Nearest)) + " GB"
        Case 10737418240 To 107374182399 ; 10 - 100 GB
            res = StrD(Round(Bytes / 107374182.4, #PB_Round_Nearest)/10.0) + " GB"
        Case 1000000000 To 10737418239 ; 1000 MB - 10 GB
            res = StrD(Round(Bytes / 10737418.24, #PB_Round_Nearest)/100.0) + " GB"
        Case 104857600 To 999999999 ; 100 - 999 MB
            res = StrD(Round(Bytes / 1048576, #PB_Round_Nearest)) + " MB"
        Case 10485760 To 104857599 ; 10 - 100 MB
            res = StrD(Round(Bytes / 104857.6, #PB_Round_Nearest)/10.0) + " MB"
        Case 1000000 To 10485759 ; 1000 KB - 10 MB
            res = StrD(Round(Bytes / 10485.76, #PB_Round_Nearest)/100.0) + " MB"
        Case 102400 To 999999 ; 100 - 999 KB
            res = StrD(Round(Bytes / 1024, #PB_Round_Nearest)) + " KB"
        Case 10240 To 102399 ; 10 - 100 KB
            res = StrD(Round(Bytes / 102.4, #PB_Round_Nearest)/10.0) + " KB"
        Case 1000 To 10239 ; 1000 B - 10 KB
            res = StrD(Round(Bytes / 10.24, #PB_Round_Nearest)/100.0) + " KB"
        Case 0 To 999
            res = StrD(Bytes )+ " B"
    EndSelect
    ProcedureReturn res
EndProcedure

Debug ShortFileSize(FileSize("C:\Windows\System32\shell32.dll"))