按键精灵怎么读取指定目录下所有文件夹名?
读取后之后保存成一个数组设成QUI里一个下拉框的列表Form1.ComboBox1.List...
读取后之后保存成一个数组 设成 QUI里 一个下拉框的 列表
Form1.ComboBox1.List 展开
Form1.ComboBox1.List 展开
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询