VB遍历所有文件
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
垃圾百度文库,非说我文档质量低,害我复制这么多,双横线以后是复制品,大家不用看这段代码是我在网上找到的,速度很快,有需要的朋友保存下吧
执行前先加个command,一■个listbox
'遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & )
Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir
= idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a")查找目录+文件
'遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String Dim a As String Dim B() As String Dim dir_i() As String Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly) Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录 idir = idir + 1
ReDim Preserve dir_i(idir) As String dir_i(idir - 1) = Myname Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If End If
Myname = Dir '搜索下一项 Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i)) Next i
ReDim dir_i(0) As String End Sub
'附:
'在这里可以处理目录中的文件
'得到文件名 '得到文件大小 '得到文件路径 '得到文件类型
'调用方法
'ShowFolderList ("c:\a") 查找目录 'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹 Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set sf = f.SubFolders For Each f1 In sf
List1.AddItem folderspec & "\" &
' 'Fn.Size 'Fn.Path 'Fn.Type
'Fn.DateLastModified
'得到文件最后的修改日期
Call ShowFolderList(folderspec & "\" & )
Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'得到文件最后的修改日期
'Fn.DateLastModified
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & )
Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件
'遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & )
Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly) Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录 idir = idir + 1
ReDim Preserve dir_i(idir) As String dir_i(idir - 1) = Myname Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If End If
Myname = Dir '搜索下一项 Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i)) Next i
ReDim dir_i(0) As String End Sub
'附:
'在这里可以处理目录中的文件
'得到文件名 '得到文件大小 '得到文件路径 '得到文件类型
'调用方法
'ShowFolderList ("c:\a") 查找目录 'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set sf = f.SubFolders For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & )
Next End Sub
' 'Fn.Size 'Fn.Path 'Fn.Type
'Fn.DateLastModified '得到文件最后的修改日期
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String) Dim Myname As String Dim a As String Dim B() As String Dim dir_i() As String Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly) Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录 idir = idir + 1
ReDim Preserve dir_i(idir) As String dir_i(idir - 1) = Myname Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If End If
Myname = Dir '搜索下一项 Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i)) Next i
ReDim dir_i(0) As String End Sub
'附:
'在这里可以处理目录中的文件
'得到文件名 '得到文件大小 '得到文件路径 '得到文件类型
'调用方法
'ShowFolderList ("c:\a") 查找目录
' 'Fn.Size 'Fn.Path 'Fn.Type
'Fn.DateLastModified
'得到文件最后的修改日期
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & )
Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List1.AddItem MyPath & Myname '把找到的文件显示到列表框中
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call SosuoFile(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
End Sub
'附:
'在这里可以处理目录中的文件
' '得到文件名
'Fn.Size '得到文件大小
'Fn.Path '得到文件路径
'Fn.Type '得到文件类型
'Fn.DateLastModified '得到文件最后的修改日期
'调用方法
'ShowFolderList ("c:\a") 查找目录
'Showfilelist ("c:\a") 查找文件
'SosuoFile ("c:\a") 查找目录+文件 '遍历文件夹
Private Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Dim hs, h, h1, hf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
List1.AddItem folderspec & "\" &
Call ShowFolderList(folderspec & "\" & ) Next
End Sub
'遍历某文件夹下的文件
Private Sub Showfilelist(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
List1.AddItem
Next
End Sub
'遍历某文件夹及子文件夹中的所有文件
Sub SosuoFile(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else。