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

前端 未结 6 1678
无人及你
无人及你 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:49

    VB6 has nothing that will do this in one click, but it's straightforward to get a list of all ZIP files (for example).

    The FSO is not recommended for a couple of reasons: one, it adds a dependency, and two, it depends on scripting, which may be disabled per policy.

    Anyway, here's a bare minimum example you can flesh out:

     Dim Fils() As String
     Dim Counter As Long
     Dim CurrentFile As String
    
     Redim Fils(0 To 999) As String
    
     CurrentFile = Dir$(yourpath & "*.zip")
    
     Do While LenB(CurrentFile)
       Fils(Counter) = CurrentFile
       Counter = Counter + 1
       CurrentFile = Dir$()
     Loop
    

    Of course, you want to add limit checking, etc, and redim as needed, but this is the basic idea.

提交回复
热议问题