zoukankan      html  css  js  c++  java
  • 查找指定文件夹下面的所有文件和其子目录下的文件

    ''=============================================
    ''名称: FindPath
    ''作用: 查找指定文件夹下面的所有文件和其子目录下的文件
    ''参数:strPath 要查找的目录,
    ''      strFiles 用于存查找结果的缓冲区,String 类型的动态数组,调用时事先初始化, 如Redim strFiles(0)
    ''      FileCount 用于返回文件个数
    ''=============================================
    Public Sub FindPath(ByVal strPath As String, strFiles() As String, FileCount As Long)
    Dim strDirs()   As String
    Dim strResult   As String
    Dim FileLimit   As Long
    Dim dirLimit    As Long
    Dim dirCount    As Long
    Dim I           As Long
        
        FileLimit = UBound(strFiles) + 1
        dirLimit = 0
        If Right$(strPath, 1) <> "" Then strPath = strPath & ""
        strResult = Dir(strPath, vbDirectory + vbSystem + vbReadOnly + vbHidden + vbNormal + vbArchive)
        Do While Len(strResult) > 0
            If strResult <> "." And strResult <> ".." Then
                If (GetAttr(strPath & strResult) And vbDirectory) <> vbDirectory Then
                    If FileCount >= FileLimit Then
                        ReDim Preserve strFiles(FileLimit + 10)
                        FileLimit = FileLimit + 10
                    End If
                    strFiles(FileCount) = strPath & strResult
                    FileCount = FileCount + 1
                Else
                    If dirCount >= dirLimit Then
                        ReDim Preserve strDirs(dirLimit + 10)
                        dirLimit = dirLimit + 10
                    End If
                    strDirs(dirCount) = strPath & strResult
                    dirCount = dirCount + 1
                End If
            End If
            strResult = Dir(, vbDirectory + vbSystem + vbReadOnly + vbHidden + vbNormal + vbArchive)
        Loop
        
        For I = 0 To dirCount - 1
            Call FindPath(strDirs(I), strFiles, FileCount)
        Next I
    End Sub
  • 相关阅读:
    移动端hybrid开发复盘
    node/webpack 调试 loader 等技巧
    javascript(js)小数精度丢失的解决方案
    必经之路--买房之后需要走的流程--针对 组合贷款方式
    canvas 画半圆的两种方式
    svg path 画圆
    1.快速排序
    7.桥接设计模式
    6.适配器设计模式
    5.策略设计模式
  • 原文地址:https://www.cnblogs.com/Spacecup/p/3642884.html
Copyright © 2011-2022 走看看