FSO 遍历文件夹和文件

前端之家收集整理的这篇文章主要介绍了FSO 遍历文件夹和文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Attribute VB_Name = "遍历文件夹和文件"
Option Explicit

Public Sub 遍历文件夹和文件(sFolder As String)
Dim fs As Object
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
File_Folder_List (fs.GetFolder(sFolder))
Set fs = Nothing
End Sub

Private Sub File_Folder_List(df As Object)

'循环处理文件集合

Dim objFile As Object,objSubFolder As Object

'文件集合
For Each objFile In df.Files
'
'
'文件处理过程
'
'
Next objFile

Set objFile = Nothing

'文件夹集合
For Each objSubFolder In df.SubFolders

'
'
'文件夹处理过程
'
'

File_Folder_List objSubFolder '递归循环处理文件

Next objSubFolder

Set objSubFolder = NothingEnd Sub

原文链接:https://www.f2er.com/vb/261263.html

猜你在找的VB相关文章