按键精灵怎么读取指定目录下所有文件夹名?

2024-11-22 15:26:05
推荐回答(1个)
回答(1):

Function FindAllFiles(FolderPath)
Dim AllFiles,fso,Folder,f,files
AllFiles = ""
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.getfolder(FolderPath)
Set files = Folder.files
For Each f In files
AllFiles = AllFiles & f.name & ","
Next
Set fso = Nothing
FindAllFiles = Split(AllFiles, ",")
End Function

//下面是调用方法:
FileEx = FindAllFiles(文件路径) //文件路径是字符串,要加双撇
If UBound(FileEx) > 0 Then
For i = 0 To UBound(FileEx) - 1
MessageBox FileEx(i)
Next
Else
MessageBox "文件夹没有文件"
End If