Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List file sizes in folders and subfolders

Status
Not open for further replies.

bf2mad

Programmer
Nov 26, 2002
33
0
0
GB
Hi,

In am using Vb6 and need a bit of help.

I need to add a feature to one of my apps where the user enters a path to a folder and then a list box displays the size of all of the files including the files in any sub folders. The files also need to be listed in size order with the filename and path.

Any ideas ?
 
I don't have time to resolve your whole problem but here is some rudimentary code to help you get started. I am sure you can find source samples that do exactly what you want.
You'd need to do some recursion probably to retrieve the files for each subfolder and the subfolders in your subfolder etc.


Dim o As New Scripting.FileSystemObject
Dim o2 As Folder
Dim f As File
Dim sf As Folder

Set o2 = o.GetFolder(Text1.Text)


For Each f In o2.Files
MsgBox f.Size & " " & f.Name
Next
For Each sf In o2.SubFolders
MsgBox sf.Name
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top