用vb.net怎样实现在遍历某一文件夹下的所有文件?

xwylpsy 2009-07-04 09:53:04
用vb.net怎样实现在遍历某一文件夹下的所有文件(包括文件和文件夹)??
...全文
1541 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xwylpsy 2009-07-04
  • 打赏
  • 举报
回复
谢谢!问题解决了!
SYSSZ 2009-07-04
  • 打赏
  • 举报
回复
Public Class Form1

Private Sub GetAllFile(ByVal path As String)
Dim strDir As String() = System.IO.Directory.GetDirectories(path)
Dim strFile As String() = System.IO.Directory.GetFiles(path)
Dim i As Integer
If strDir.Length > 0 Then
For i = 0 To strDir.Length - 1
Debug.Print(strDir(i))
Next
End If

If strFile.Length > 0 Then

For i = 0 To strFile.Length - 1
Debug.Print(strFile(i))
Next
End If
If strDir.Length > 0 Then
For i = 0 To strDir.Length - 1

GetAllFile(strDir(i))
Next
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GetAllFile("e:\PIC")
End Sub
End Class
xwylpsy 2009-07-04
  • 打赏
  • 举报
回复
我是想要用递归的方法把一个文件夹下的所有文件、文件夹都找出来!
CloneCenter 2009-07-04
  • 打赏
  • 举报
回复
不行?怎么不行?自己代码怎么写的?最起码要贴出来,大家才能帮你看。
xwylpsy 2009-07-04
  • 打赏
  • 举报
回复
不行呀!急急!!!各位帮帮忙
kkun_3yue3 2009-07-04
  • 打赏
  • 举报
回复
开始->运行->输入
tree /f /a C:\目录名称 >文件树sql.txt

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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