Can you help me in determining the size of a Folder using VB 6
Printable View
Can you help me in determining the size of a Folder using VB 6
I gave a try and the following code works
here it is
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\shammy")
MsgBox (f.Size())
Ok guys, I tried this today:
VB Code:
Private Sub cmdWindowsFolderSize_Click() Dim objFSO As FileSystemObject Dim objFolder As Folder Set objFSO = New FileSystemObject Set objFolder = objFSO.GetFolder("C:\Windows") MsgBox objFolder.Size End Sub
And it gives "User-defined type not defined" and it highlights the objFSO As FileSystemObject bit. :(
What I am missing here?
Thanks your help.
Edit: Thank you very much vbNeo and dis1411 (for project -> references, and check Microsoft Scripting Runtime). :)
try including the 'Microsoft Scripting Runtime' as a reference to you project.
Thanks vbNeo for the help!
One more thing: VB doesn't seem to understand the %SystemRoot% command.
Any alternative for that guys?
VB Code:
'Downloads Set objFSO = New FileSystemObject Set objFolder = objFSO.GetFolder("%SystemRoot%\Downloads") dblDownloads = objFolder.Size txtDownloads.Text = dblDownloads / 1048576
Any help for the above post guys?
I know that:
FS.GetSpecialFolder(0) - Gives Windows folder path
fs.GetSpecialFolder(1) - Gives SystemFolder Path
fs.GetSpecialFolder(2) - Gives Temp folder Path
where Fs is the filesystemobject
But, I want only C: (as in %SYSTEMROOT%, not C:\Windows.
Thanks again.
try
msgbox environ("SystemDrive")
Awesome! The following code worked like a charm.
VB Code:
'Downloads Set objFSO = New FileSystemObject Set objFolder = objFSO.GetFolder(Environ("SystemDrive") & ("\Downloads")) dblDownloads = objFolder.Size txtDownloads.Text = FormatNumber((dblDownloads / 1048576), 2)
You da MAN dude. :)