按键精灵怎么读取指定目录下所有文件夹名 5
读取后之后保存成一个数组设成QUI里一个下拉框的列表Form1.ComboBox1.List...
读取后之后保存成一个数组 设成 QUI里 一个下拉框的 列表
Form1.ComboBox1.List 展开
Form1.ComboBox1.List 展开
展开全部
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
推荐于2018-03-01
展开全部
读取文件夹名,参考实例如下:
文件夹="C:\百度\"
Set F = CreateObject("Scripting.FileSystemObject")
If Not F.FolderExists(文件夹) Then
MsgBox "未检测到文件夹"
End If
Set oF = F.GetFolder(文件夹)
For Each a In oF.Files
MSGBOX a.NAME
NEXT
文件夹="C:\百度\"
Set F = CreateObject("Scripting.FileSystemObject")
If Not F.FolderExists(文件夹) Then
MsgBox "未检测到文件夹"
End If
Set oF = F.GetFolder(文件夹)
For Each a In oF.Files
MSGBOX a.NAME
NEXT
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询