VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



RecurseFolderList

by Scott Brown (3 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code is a modified version of ShowFolderList by Bruce Lindsay. (Thanx !!) This code will recursively parse a directory defined by an path parameter. My aim was to work around
the non-recursive nature of the dir function. Bruce's original code does that to one folder/child level. Mine now returns everything below a given path. You can still use getattr to define Folder or File attributes.

Inputs
foldername - "c:\temp"
Side Effects
No error trapping, untested on VB3/4

Rate RecurseFolderList

Function RecurseFolderList(foldername)
 Dim fso, f, fc, fj, f1
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.GetFolder(foldername)
 Set fc = f.Subfolders
 Set fj = f.Files
    
 'For each subfolder in the Folder
 For Each f1 In fc
  'Do something with the Folder Name
  debug.print f1
  'Then recurse this function with the sub-folder to get any sub-folders
  RecurseFolderList(f1)
 Next
 
 'For each folder check for any files
 For Each f1 In fj
  debug.print f1
 Next
End Function

Download this snippet    Add to My Saved Code

RecurseFolderList Comments

No comments have been posted about RecurseFolderList. Why not be the first to post a comment about RecurseFolderList.

Post your comment

Subject:
Message:
0/1000 characters