0

In VB6, I am using a Webbrowser form to display all files and subfolders as icons in the style of Windows Explorer. On the form, I display a count of all files in the main folder and all subfolders. This is my code so far, though haven't been able to find any information about counting subfolders.

Private Sub Load_Form()      
    Dim myPathName as String
    Dim iTotalCount as Long
    some stuff here ....
    WebBrowser1.Navigate myPathName
    WebBrowser1.Document.CurrentViewMode = 5   'medium icons
    iTotalCount = FileCount(myPathName)
    lblLabel.Caption = "Total Files = " & iTotalCount
    more stuff here ....
End Sub

Public Function FileCount(myPathName as String) as Long
    Dim FSO as New FileSystemObject
    Dim fld as Folder
    If FSO.FolderExists(myPathName) Then
        Set fld = FSO.GetFolder(myPathName)
        FileCount = fld.Files.Count
    End If
End Function

This StackOverFlow question is similar, though for vb.net (which I don't know). I'd appreciate someone pointing me in the right direction. Many thanks.

  • Does this answer your question? [count how many of files in each folder and subfolder then display separately](https://stackoverflow.com/questions/38391938/count-how-many-of-files-in-each-folder-and-subfolder-then-display-separately) – Étienne Laneville Feb 02 '21 at 04:04
  • Étienne, thanks for your input and suggesting this link. I tried, however, couldn't get it to work. However, thread #5 in this link (https://www.vbforums.com/showthread.php?288321-Count-Files-in-Folder-amp-Subfolders-have-searched-to-no-avail!) worked perfectly. Counts files in the main folder and all sub-folders. – user15120209 Feb 03 '21 at 06:26

0 Answers0