'strDDir 要检索的目录,strSearchChr 要检索的文件名
Private Function SetFileRB(ByVal strDDir As String, ByVal strSearchChr As String) As Integer
Dim dirInfo As New DirectoryInfo(strDDir)
Dim intCnt As Integer = 1
Dim intTemp As Integer = 0
If dirInfo.Exists Then
Dim files As FileInfo() = dirInfo.GetFiles(strSearchChr)
Dim i As Integer
For i = 0 To files.Length - 1
'自己的处理
Next
End If
Return intCnt
End Function
String[] files = Directory.GetFiles("BasePath", "*autoCAD2005\acad.exe");//*匹配路径
然后是对BasePath的递归查找,如果是你全匹配的返回路径。
System.IO.Directory.GetFiles("BasePath", "acad.exe", SearchOption.AllDirectories);
这样就可以了。