如何读取文件夹下的所有文件名

kata 2002-04-27 03:15:47
问一下,在vb里如何从选的文件夹中读其所包含的所有文件名。
...全文
262 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dragoonLee 2002-04-27
  • 打赏
  • 举报
回复
'调用Project-->References-->Microsoft Scripting Runtime
Dim fso As New FileSystemObject
Dim fi, fc, f
Set f = fso.GetFolder(你的文件名)
'得到临时文件夹全部文件

Set fc = f.Files

'文件夹不存在,退出
If Not fso.FolderExists(你的文件名) Then Exit Sub

For Each f1 In fc '编历
debug.print f1.name
Next
lily0000000 2002-04-27
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim i As String
i = Dir(App.Path & "\*.*", vbReadOnly)
Do While i <> ""
MsgBox i
i = Dir
Loop
End Sub
gump2000 2002-04-27
  • 打赏
  • 举报
回复
dim buf as string


buf=dir("i:\*.*")
do whilr buf<>""
if buf<>"." and buf<>".." then
debug.print buf
end if
buf=dir
loop
viperstorm 2002-04-27
  • 打赏
  • 举报
回复
LOOK:
http://www.r4cn.com/resource/index.htm -->>
cSearchFile.cls 搜索文件的类。
lily0000000 2002-04-27
  • 打赏
  • 举报
回复
dir(文件夹路径)

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧