不使用fileSystem组件,叫你列举出文件夹下的所以文件包括子文件夹

'转载请保留 3q2008.com 许仙
'*************************************************************************
' 功能描述:'列举文件夹下的所有文件名,加到数组里  传入变体型返回数组 strFolder 后没用/
'*************************************************************************
Public Function ListFolderFiles(ByRef myArrayFiles, strFolder As String)
    Dim strFileName As String
    Dim intI As Integer
    strFileName = Dir(strFolder & "/")
    If strFileName <> "" Then
        ReDim myArrayFiles(0) As String
        intI = 0
        While strFileName <> ""
            ReDim Preserve myArrayFiles(intI) As String
            myArrayFiles(intI) = strFolder & "/" & strFileName
            intI = intI + 1
            strFileName = Dir()
        Wend
    End If
End Function


'*************************************************************************
'列举出文件夹下的所以文件夹 sFolderPath 后要有/
'Print GetFoder("c:/")
'|*|WINDOWS|*|Temp|*|VF|*|Documents and Settings|*|Program Files|*|word知识|*|senty|*|tempdir
'*************************************************************************

Public Function GetFoder(sFolderPath As String)

    Dim sFile As String
    Dim sFolderName As String
    Dim sMainFolder$
    '输入的文件夹名
   
    sFile = Dir(sFolderPath, vbDirectory)
    If sFile <> "" Then
        While sFile <> ""
            If GetAttr(sFolderPath & sFile) = vbDirectory Then
                If sFile <> "." And sFile <> ".." Then
                    '获得文件夹后的代码
                    'Debug.Print sFolderPath & sFile
                    sFolderName = sFolderName & "|*|" & sFile
                    GetFoder = sFolderName
                End If
            End If
            sFile = Dir()
        Wend
    End If
End Function


'列举所以文件夹
'返回用 **分开的文件字符串
Public Function ListFolder(sPath As String) As String
    Dim sFileName$, MyMarry
    sFileName = Dir(sPath & "/*.*")
    Do Until sFileName = ""
        If GetAttr(sPath) = vbDirectory Then
            ListFolderFiles MyMarry, sFileName
        End If

    Loop
End Function

这个三个函数,不使用fileSystem组件,叫你列举出文件夹下的所以文件包括子文件夹

不使用fileSystem组件,叫你列举出文件夹下的所以文件包括子文件夹 ,几个月前写的,也没整理,应该是可以正常使用的,使用递归调用就OK了
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值