谢谢大红袍老师了,我也想明白了。测试了一下,这个$RECYCLE.BIN特殊文件是在GetDirectories这里出现的,和文件夹差不多的。所以直接用字符串判断一下,排除就好了。隐藏文件也把它筛选来。测试可行了。今天对递归重新复习了。谢谢了!![dvubb](images/emot/em218.gif)
**********************************
窗口1_Button1_Click
Functions.Execute("递归", "F:\")
自定义函数
递归
Dim path As String = args(0)
For Each file As String In FileSys.GetFiles(path)
' Dim ifo As new FileInfo(file)
' If ifo.Hidden = False Then '如果文件不是隐藏属性
Forms("窗口1").Controls("TextBox1").Text &= vbcrlf & file & vbcrlf
' End If
Next
For Each p As String In FileSys.GetDirectories(path)
If p.Contains("$") = False Then '排除特殊的文件,如:$RECYCLE.BIN
Forms("窗口1").Controls("TextBox1").Text &= vbcrlf & p & vbcrlf
Functions.Execute("递归", p)
End If
Next
全局代码