Login
网站首页 > 文章中心 > VB6

VB得到指定文件夹下的文件列表

作者:小编 更新时间:2024-08-06 17:39:12 浏览量:82人看过

代码如下:



Function GetFileList(ByVal Path As String, ByRef FileName() As String, Optional fExp As String = "*.*") As Boolean

    Dim fName As String, i As Long

    If Right$(Path, 1) <> "" Then Path = Path & ""

    fName = Dir$(Path & fExp)

    i = 0

    Do While fName <> ""

        ReDim Preserve FileName(i) As String

        FileName(i) = fName

        fName = Dir$

        i = i + 1

    Loop

    If i <> 0 Then

        ReDim Preserve FileName(i - 1) As String

        GetFileList = True

    Else

        GetFileList = False

    End If


End Function


Private Sub Command1_Click()

    Dim FileName() As String, i As Long

    GetFileList "c:", FileName, "*.mp3" '可以设置文件类型

    For i = 0 To UBound(FileName)

        Print FileName(i)

    Next i


End Sub



版权声明:倡导尊重与保护知识产权,本站有部分资源、图片来源于网络,如有侵权,请联系我们修改或者删除处理。
转载请说明来源于"土嘎嘎" 本文地址:http://www.tugaga.com/jishu/vb/1883.html
<<上一篇 2024-08-06
下一篇 >> 2024-08-06

编辑推荐

热门文章