扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '函数GetExtName '功能:得到文件后缀名(扩展名) '输入:文件名 '输出:文件后缀名(扩展名) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function GetExtName(strFileName As String) As String Dim strTmp As String Dim strByte As String Dim i As Long For i = Len(strFileName) To 1 Step -1 strByte = Mid(strFileName, i, 1) If strByte <> "." Then strTmp = strByte + strTmp Else Exit For End If Next i GetExtName = strTmp End Function Public Function search(ByVal strPath As String, Optional strSearch As String = "") As Boolean Dim strFileDir() As String Dim strFile As String Dim i As Long Dim lDirCount As Long On Error GoTo MyErr If Right(strPath, 1) <> "\" Then strPath = strPath + "\" strFile = Dir(strPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly) While strFile <> "" '搜索当前目录 DoEvents If (GetAttr(strPath + strFile) And vbDirectory) = vbDirectory Then '如果找到的是目录 If strFile <> "." And strFile <> ".." Then '排除掉父目录(..)和当前目录(.) lDirCount = lDirCount + 1 '将目录数增1 ReDim Preserve strFileDir(lDirCount) As String strFileDir(lDirCount - 1) = strFile '用动态数组保存当前目录名 End If Else If strSearch = "" Then Form1.List1.AddItem strPath + strFile ElseIf LCase(GetExtName(strPath + strFile)) = LCase(GetExtName(strSearch)) Then '满足搜索条件,则处理该文件 Form1.List1.AddItem strPath + strFile '将文件全名保存至列表框List1中 End If End If strFile = Dir Wend For i = 0 To lDirCount - 1 Form1.Label3.Caption = strPath + strFileDir(i) Call search(strPath + strFileDir(i), strSearch) '递归搜索子目录 Next ReDim strFileDir(0) '将动态数组清空 search = True '搜索成功 Exit Function MyErr: search = False '搜索失败 End Function |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者