MyTetra Share
Делитесь знаниями!
размер папки(VolumeFolder)
12.01.2018
11:54
Текстовые метки: VolumeFolder, размер папкиб FSO, GetFolder,GetDrive
Раздел: VBA - FSO

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

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

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

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

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

Sub test_VolumeFolder()

Dim vSize As Long

strPath = "I:\0ru_di\Peinture\"

strPath = "\\rudh002113\share_\DPU\"

strPath = "I:\0ru_di\Peinture\TPM\"

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("I:\0ru_di\Peinture\")

Set Folder = fso.GetFolder("d:\LocalData\au11101\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.52
Яндекс индекс цитирования