Collection of all File objects within a folder.
Examples
The following code illustrates how to get a Files collection and iterate the collection by using the For Each...Next statement.
Function ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
s = s & f1.Name
s = s & vbCrLf
Next
Debug.Print s
End Function
Run this code in Immediate Window:
Debug.Print ShowFolderList("D:\TestFolder")
Result:
hidden.txt
hidden_readonly.txt
readonly.txt