Question : VBScript - Capture Folder Contents Into Array

I need to capture the contents (filename and filesize only) of a folder into a two-dimensional array.

For example - from the path "C:\TEMP\FOLDER23", I would want the script to capture the names of all the files along with the sizes of all the files, and put the data into a two-dimensional array named"aFileNameSize".

I would hope that a query of the array would produce:

         strFileName = aFileNameSize(0,0)
         intFileSize = aFileNameSize(0,1)

         Msgbox strFileName & ", " & intFileSize

       Display:  GeeseInThePark.pdf, 3596238

Thank you...DavidS

Answer : VBScript - Capture Folder Contents Into Array

if hope i understand

path in line 1
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
strFolder = "C:\TEMP\FOLDER23"
Dim aFileNameSize(0, 1)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colFolder = objFSO.GetFolder(strFolder)
Set colFiles = colFolder.Files

For Each strFile In colFiles
aFileNameSize(0,0) = strfile.name
aFileNameSize(0,1) = strfile.size
strFileName = aFileNameSize(0,0)
intFileSize = aFileNameSize(0,1)
MsgBox strFileName & ", " & intFileSize & " bytes"
Next
Random Solutions  
 
programming4us programming4us