Dowload Source Code: Source Code
Use the Visual Basic 2005 My.Compuer.FileSystem.GetFiles method to search for files.
The My.Computer.FileSystem.GetFiles Method returns a read-only collection of strings representing the name of the files within a directory. Use the wildCards parameter of the GetFiles method to specify a specific file name pattern. Set the searchType parameter of the GetFiles method to search only the root of a directory or a directory and all its subdirectories.
EXAMPLE CODE
Protected Function SearchForFiles(ByVal directory As String, ByVal searchOption As Microsoft.VisualBasic.FileIO.SearchOption, ByVal wildCards As String) As String
Dim returnValue As String = ""
Try
For Each foundFile As String In My.Computer.FileSystem.GetFiles(directory, searchOption, wildCards)
returnValue &= foundFile & Environment.NewLine
Next
Catch ex As Exception
MessageBox.Show("Exception thrown: " & ex.Message)
End Try
Return returnValue
End Function
Click the link above to download Visual Basic source code in a Visual Studio 2005 solution which demonstrates how to use the My.Computer.FileSystem GetFiles method to search for files.
Mike McIntyre
Get Dot Net Code