any function for listing out all the files of a specified type in a folder in VB6

前端 未结 6 1679
无人及你
无人及你 2020-12-04 03:36

I would like to know if there are some in built functions for the scenario that is described below :

The input is the path of a parent folder. Wat the function must

6条回答
  •  伪装坚强ぢ
    2020-12-04 03:54

    In VB6 you want to use FileSystemObject of the Microsoft Scripting Runtime. You can access to the scripting runtime by setting a reference to it.

    The .NET framework has a similar but more capable set of file/directory handling object in the System.IO namespace

    The following an example of how to use FileSystemObject in VB6.

    Dim FSO As FileSystemObject
    Dim Folder As Folder
    Dim SubFolder As Folder
    Dim File As File
    
    Set FSO = New FileSystemObject
    
    Set Folder = FSO.GetFolder("C:\")
    For Each File In Folder.Files
        Debug.Print File.Name
    Next File
    
    For Each SubFolder In Folder.SubFolders
        Debug.Print SubFolder.Name
    Next SubFolder
    
    Set Folder = Nothing
    Set SubFolder = Nothing
    Set FSO = Nothing
    

提交回复
热议问题