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!

Get size and number of files properties of a folder.

Status
Not open for further replies.

OrionCookies

Programmer
May 5, 2005
43
0
0
US
Hi guys,
I am trying to retrieve properties of a folder. I know folder exists, but i am getting path not found on line 13 and 14 where it mentioned to retrieve size and files. here is the code...thanks for help in advance.

****************************************************
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\\grpwise")
Wscript.Echo "Date created: " & objFolder.DateCreated
Wscript.Echo "Date last accessed: " & objFolder.DateLastAccessed
Wscript.Echo "Date last modified: " & objFolder.DateLastModified
Wscript.Echo "Drive: " & objFolder.Drive
Wscript.Echo "Is root folder: " & objFolder.IsRootFolder
Wscript.Echo "Name: " & objFolder.Name
Wscript.Echo "Parent folder: " & objFolder.ParentFolder
Wscript.Echo "Path: " & objFolder.Path
Wscript.Echo "Short name: " & objFolder.ShortName
Wscript.Echo "Short path: " & objFolder.ShortPath
Wscript.Echo "Size: " & objFolder.Size
Wscript.Echo "Files: " & objFolder.Files
****************************************************
 
ok found the issues and resolve size properties.

but my files property still doesn't work
it says wrong number of argument or invalid property assignment
 
Unless you actually want to echo each file name. Files is a collection, meaning that it is a large list of file OBJECTS.
If you want to list each one, you could do it with a For Each loop:
Code:
Wscript.Echo "Files:"
For Each strListFile in objFolder.Files
    Wscript.Echo "-  " & strListFile.Name
Next strListFile

Furthermore, File Objects have many Member Class Functions and Properties. So you could list their other attributes, such as size, date created, date modified, owner, etc.

All mentioned Member Class Functions and Properties are listed in the Visual Basic Reference Library. Check them out! It's fun.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top