|
-
November 4th, 1999, 11:19 PM
#1
Directories & Files
Hi,
How does one determine the number of files in a directory and the size (MB) of that directory?
Thanks,
Rob
-
November 5th, 1999, 02:39 AM
#2
Re: Directories & Files
I'd loop through all files using the Dir function and sum the file size by means of the FileLen function.
-
November 5th, 1999, 02:55 AM
#3
Re: Directories & Files
e.g.
private Sub Command1_Click()
Dim iCount as Integer
Dim lSize as Long
iCount = GetDirCount("c:\winnt", lSize)
MsgBox iCount & " files; " & lSize & " BYtes"
End Sub
Function GetDirCount(byval strPath as string, byref lSize as Long) as Integer
lSize = 0
Dim iCount as Integer
Dim strFile as string
If Right(strPath, 1) <> "\" then strPath = strPath & "\"
strFile = Dir(strPath & "*.*")
Do While strFile <> ""
iCount = iCount + 1
strFile = strPath & strFile
lSize = lSize + FileLen(strFile)
strFile = Dir
Loop
GetDirCount = iCount
End Function
-
April 3rd, 2000, 12:22 PM
#4
Expand on this?
How can you use that to find out the total size of a directory? Not just files in the immediate directory.
-
April 4th, 2000, 08:27 AM
#5
Re: Expand on this?
I don't know why nobody has answered this yet, so here it is:
private Function GetFolderSize(folderpath) as Double
Dim fs, f, s
set fs = CreateObject("Scripting.FileSystemObject")
set f = fs.GetFolder(folderpath)
on error resume next
GetFolderSize = f.Size
End Function
It's not that hard, is it? I hope that's what you wanted.
"I'm not biased, I'm Christian."
-
April 10th, 2000, 12:18 PM
#6
Re: Expand on this?
THANKS!!! That's exactly what I wanted! Not this crap about listing files. It seems like you are the only one who can understand English. Thanks again!
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
|