Find Folder Size
Hi ,
You can use this :
Private Sub UserForm_Activate()
Dim Drv As Scripting.FileSystemObject
Dim Filesx As Scripting.File
Dim SourceFolder As Scripting.Folder
Set Drv = New Scripting.FileSystemObject
Set SourceFolder = Drv.GetFolder("c:\")
' List of files in your c:\ drive
For Each Filesx In SourceFolder.Files
ListBox1.AddItem Filesx.Name
Next Filesx
' List of sizes in your c:\ drive
msg = "Used space: " & _
FormatNumber(Drv.GetDrive("c:\").TotalSize - _
Drv.GetDrive("c:\").FreeSpace, 0)
msg = msg & vbCr & "Free space: " & _
FormatNumber(Drv.GetDrive("c:\").FreeSpace, 0)
msg = msg & vbCr & "Capacity: " & _
FormatNumber(Drv.GetDrive("c:\").TotalSize, 0)
MsgBox msg, vbInformation, "Drive c:\"
End Sub
but before run you have to add your VBA references with
Microsoft Scripting runtime
from ToolsReferences
and check "Microsoft Scripting runtime" box
--
Regards,
Halim
"vqthomf" wrote:
Hi Is it possible to find a folder size, and also how can I list duplicate
files into a listbox any help will be much appreciated thanks.
Charles
|