|
-
Oct 22nd, 2003, 01:27 PM
#1
Thread Starter
New Member
Directory Size
Can you help me in determining the size of a Folder using VB 6
-
Oct 22nd, 2003, 01:56 PM
#2
Thread Starter
New Member
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())
-
Nov 20th, 2003, 10:36 AM
#3
Addicted Member
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).
Last edited by ~*McoreD*~; Nov 20th, 2003 at 10:57 AM.
-
Nov 20th, 2003, 10:38 AM
#4
Frenzied Member
Well
try including the 'Microsoft Scripting Runtime' as a reference to you project.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Nov 20th, 2003, 12:21 PM
#5
Addicted Member
Thank you!
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
-
Nov 21st, 2003, 10:56 PM
#6
Addicted Member
%SystemRoot% Alternative
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.
-
Nov 21st, 2003, 11:18 PM
#7
The picture isn't missing
try
msgbox environ("SystemDrive")
-
Nov 22nd, 2003, 12:38 AM
#8
Addicted Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|