MyTetra Share
Делитесь знаниями!
размер папки(VolumeFolder)
Время создания: 16.03.2019 23:43
Текстовые метки: VolumeFolder, размер папки, FSO, GetFolder,GetDrive
Раздел: Разные закладки - VBA - FSO
Запись: xintrea/mytetra_db_adgaver_new/master/base/1515747291blfraxkrmn/text.html на raw.githubusercontent.com

'=================================================================

'##### считываем размер папки (кроме сетевых)

'vVal - исходное значение

'bCom - добавить единицу езмерения

'-----------------------------------------------------------------

Sub test_VolumeFolder()

Dim vSize As Long

    strPath = ""

    strPath = ""

    strPath = ""

    sSize = VolumeFolder(strPath)

    vSize = Fn_FormatSize(sSize, False)

End Sub

 

Function VolumeFolder(path)

    Dim fso As Object, fold As Object

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set fold = fso.GetFolder(path)

    VolumeFolder = fold.Size

    Set fso = Nothing

    Set fold = Nothing

End Function

'=================================================================

 

'=================================================================

'##### форматирует размер в читаемый вид

'vVal - исходное значение

'bCom - добавить единицу езмерения

'-----------------------------------------------------------------

Function Fn_FormatSize( _

                ByVal vVal As Variant, _

                ByVal bCom As Boolean) As Variant

Dim strVal As String

'Fn_FormatSize = Format$(vVal, "# ##0.00"): strVal = " байт"

    Select Case vVal

        Case vVal < 1024

            Fn_FormatSize = Format$(vVal, "0.00"): strVal = " байт"

        Case vVal < 1048576

            Fn_FormatSize = Format$(vVal / 1024, "0.00"): strVal = " кб."

        Case Else

            Fn_FormatSize = Format$(vVal / 1048576, "0.00"): strVal = " мб."

    End Select

   

    If bCom Then Fn_FormatSize = Fn_FormatSize & strVal

End Function

'=================================================================

 

Sub test_GetDrive()

'MsgBox Drive.FileSystem

'Set Drive = FSO.GetDrive("C:\")

'MsgBox Drive.FileSystem

 

'''Drive

'Dim lngSpaceTree

'Set fso = CreateObject("Scripting.FileSystemObject")

'Set Drive = fso.GetDrive("I:")

'lngSpaceTree = Drive.FreeSpace

'

'    Select Case lngSpaceTree

'    Case lngSpaceTree < 1024

'        strMsg = Format$(lngSpaceTree, "# ##0.00") & " байт"

'    Case lngSpaceTree < 1048576

'        strMsg = Format$(lngSpaceTree / 1024, "# ##0.00") & " кб."

'    Case Else

'        strMsg = Format$(lngSpaceTree / 1048576, "# ##0.00") & " мб."

'    End Select

'    Debug.Print strMsg

   

''Folder

Set fso = CreateObject("Scripting.FileSystemObject")

'Set Folder = fso.GetFolder("")

Set Folder = fso.GetFolder("d:\LocalData\username\Desktop\BO Prod\")

''MsgBox Folder.ShortName

Stop

    ': AvailableSpace : 87097925632 : Variant/Double

    Debug.Print "AvailableSpace - " & Format$(Folder.Drive.AvailableSpace / 1048576, "# ##0.00") & " мб."

    '      : FreeSpace : 87097925632 : Variant/Double

    Debug.Print "FreeSpace - " & Format$(Folder.Drive.FreeSpace / 1048576, "# ##0.00") & " мб."

    '      : TotalSize : 989560467456 : Variant/Double

    Debug.Print "TotalSize - " & Format$(Folder.Drive.TotalSize / 1048576, "# ##0.00") & " мб."

End Sub

 

 

 

 

 

 

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования