下面的代码我也看了很多遍,可是增加递归函数时s参数总出错,不知道哪里的问题,想用窗口“提取所有文件名称”按钮提取,请老师帮忙看一下,怎么完善一下?谢谢!
内部函数,函数名:递归,代码:
Dim path As String = args(0)
Dim ls As List(of String) = args(1)
For Each file As String In FileSys.GetFiles(path)
Dim finfo As new FileInfo(file)
If finfo.Hidden = False Then
ls.add(file)
End If
Next
For Each p As String In FileSys.GetDirectories(path)
Dim s As new System.Security.AccessControl.DirectorySecurity(p, System.Security.AccessControl.AccessControlSections.Access)
If s.AreAccessRulesProtected = False Then
Functions.Execute("递归", p, ls)
End If
Next
调用测试:
Dim lst As new List(of String)
Functions.Execute("递归", "C:\foxtable\Development",lst)
MessageBox.show(lst.Count)
测试通过
内部函数,函数名:递归,代码:
Dim path As String = args(0)
Dim ls As List(of String) = args(1)
Dim s1 As List(of String) = args(2)
For Each file As String In FileSys.GetFiles(path)
If file.Contains(s1) Then
Dim finfo As new FileInfo(file)
If finfo.Hidden = False Then
ls.add(file)
End If
End If
Next
For Each p As String In FileSys.GetDirectories(path)
Dim s As new System.Security.AccessControl.DirectorySecurity(p, System.Security.AccessControl.AccessControlSections.Access)
If s.AreAccessRulesProtected = False Then
Functions.Execute("递归", p, ls)
End If
Next
调用测试:
Dim lst As new List(of String)
Dim s1 As String = e.Form.Controls("TextBox3").text
Functions.Execute("递归", "C:\foxtable\Development",lst,s1)
MessageBox.show(lst.Count)