按键精灵 遍历文件夹内的所有文件名保存在一个数组里然后怎么样才可以每次输出一个结果
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询