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