遍历文件夹内的所有文件名保存在一个数组里然后怎么样才可以每次输出一个结果?
Function FindAllFiles(FolderPath)Dim AllFiles,fso,Folder,f,filesAllFiles = ""Set fso = CreateObject("Scripting.FileSystemObject"
)Set Folder = fso.getfolder(FolderPath)Set files = Folder.filesFor Each f In filesAllFiles = AllFiles & f.name & ","NextSet fso = NothingFindAllFiles = Split(AllFiles, ",")End Function//下面是调用方法:
FileEx = FindAllFiles(文件路径) //文件路径是字符串,要加双撇If UBound(FileEx) > 0 ThenFor i = 0 To UBound(FileEx) - 1MessageBox FileEx(i)NextElseMessageBox "文件夹没有文件"End If