读取后之后保存成一个数组 设成 QUI里 一个下拉框的 列表
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
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于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本回答被网友采纳