Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub GetFileListing()
Dim strFolder As String
strFolder = "C:\Program Files"
SearchSubfolders (strFolder)
End Sub
Sub SearchSubfolders(strMainFolder As String)
Dim objMainFolder 'Holds main folder
Dim objFSO As Object 'So we can use the File System Object
Dim objFile As Object 'Holds the file objects
Dim objSubfolders As Object 'Holds the subfolder objects
Dim strFileName As String 'Holds the string name of the file
Dim objFileDest As Object 'File we are creating the log on
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objMainFolder = objFSO.GetFolder(strMainFolder)
For Each objFile In objMainFolder.Files
strFileName = objFile.Name
Set objFileDest = objFSO.OpenTextFile("C:\Temp\AllFiles.txt", 8, True)
objFileDest.WriteLine objMainFolder.Name & "\" & objFile.Name & "," & objFile.Size
Set objFileDest = Nothing
Next
For Each objSubfolders In objMainFolder.subfolders
SearchSubfolders (objSubfolders)
Next
Set objMainFolder = Nothing
Set objFSO = Nothing
Set objFile = Nothing
Set objSubfolders = Nothing
End Sub
Sub SearchSubfolders(strMainFolder As String)
Dim fso As Scripting.FileSystemObject
Dim oFile As Scripting.File
Dim ioFileOut As Scripting.TextStream
Dim oParentFolder As Scripting.Folder
Dim oChildFolder As Scripting.Folder
Set fso = New Scripting.FileSystemObject
Set oParentFolder = fso.GetFolder(strMainFolder)
For Each oFile In oParentFolder.Files
Set ioFileOut = fso.OpenTextFile("C:\AllFiles.txt", ForAppending, True)
ioFileOut.WriteLine [blue]oParentFolder.Path[/blue] & "\" & oFile.Name & _
[blue]" (" & Round((oFile.Size / 1024) + 0.5) & " KB)"[/blue]
Set ioFileOut = Nothing
Next
For Each oChildFolder In oParentFolder.SubFolders
SearchSubfolders (oChildFolder)
Next
Set oChildFolder = Nothing
Set oParentFolder = Nothing
Set oFile = Nothing
Set fso = Nothing
End Sub