’sPath是所查找的文件夹的路径,list是返回的文件列表
Public Function GetAllFiles(ByVal sPath As String, list As Collection)
Dim item As String
Dim oPaths As New Collection
item = Dir(sPath, vbDirectory)
While Len(item) > 0
If item <> "." And item <> ".." Then
If (GetAttr(FullPathName(sPath) & item) And vbDirectory) = vbDirectory Then
oPaths.Add item
Else
If IsModelFile(item) Then list.Add sPath & item
End If
End If
item = Dir
Wend
Dim p
For Each p In oPaths
Call GetAllFiles(Combin(sPath, p), list)
Next
End Function
’判断文件夹后是否有\
Public Function FullPathName(ByVal strPath As String) As String
FullPathName = IIf(VBA.Right(strPath, 1) = "\", strPath, strPath & "\")
End Function
’多个文件夹名组成路径
Public Function Combin(ParamArray arg()) As String
Dim X
Dim result As String
For Each X In arg()
result = result & FullPathName(X)
Next
Combin = result
End Function
本文来自 280文秘网(https://www.it280.com),转载请保留网址和出处
【visualbasic6.0遍历文件夹下所有文件代码】相关文章:
Vb中控件的自动排列05-07
写未来的作文300字05-07
小学父爱的作文600字05-07
荷花作文600字05-07
07年4月北师大“中国古代文学史(一)”串讲(5)05-07
寓言作文300字05-07
汪涵讲述小时候成长经历:鸡毛掸子的故事05-07
关于清明节的英语作文:清明节05-07
嘿我成功了作文05-07
生态护坡技术创新措施论文05-07
感恩作文800字:关于感恩父母05-07
