如何检查子文件夹是否存在VB6

Ber*_*eer 0 vb6

几十年来我一直在寻找这个没有成功的人.我需要找出是否存在我给出该名称的子文件夹..

For i = 0 To 3 'got 4 different loc to check sub folders
    Set f = fso.GetFolder(backupdir(i)) 
    Set sf = f.SubFolders
    For Each fr In sf 'for each folder in sub folder
        Do Until fr = "" Or fr = Null 
            If fso.FolderExists(fr.SubFolders) Then 
            'if more sub folders exist i wanna make sure
            'that i can get their subfolders too
            'till there is no sub folder left..
                sf = fr
            End If
        Loop
    Next fr
Next i
Run Code Online (Sandbox Code Playgroud)

Ale*_* K. 5

遍历文件夹文件夹的操作称为递归.

用FindFirstFile:对于文件夹使用文件夹面膜(最少的代码)递归搜索例如这里展示了如何使用Windows API很快做到这一点.