Browsing files in a folder using VB.NET
This small piece of code will give an idea to browse file in a given folder.
Start your VB.NET application and create a new project (Ctrl+Shift+N) in Windows Application and design your form as you like. I have design my form as below (Figure 1.):

Now drag a FolderBrowseDialog from Toolbox and name it FolderBrowserDialog1.
On click event of btnBrowse open FolderBrowserDialog1 to select folder and then assign that path to txtPath.
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
FolderBrowserDialog1.ShowDialog()
txtPath.Text = FolderBrowserDialog1.SelectedPath
End Sub
Now on Click event of btnSearch we have to search test pattern. Following piece of code will do it for you.
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
lstSeachResult.Items.Clear()
Dim dir_info As New DirectoryInfo(txtPath.Text)
Dim file_infos() As FileInfo
file_infos = dir_info.GetFiles(txtsearch.Text)
For Each file_info As FileInfo In file_infos
lstSeachResult.Items.Add(file_info.Name)
Next file_info
End Sub
Now your complete code will look like as below:
Imports System.IO
Public Class Form1
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
FolderBrowserDialog1.ShowDialog()
txtPath.Text = FolderBrowserDialog1.SelectedPath
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
lstSeachResult.Items.Clear()
Dim dir_info As New DirectoryInfo(txtPath.Text)
Dim file_infos() As FileInfo
file_infos = dir_info.GetFiles(txtsearch.Text)
For Each file_info As FileInfo In file_infos
lstSeachResult.Items.Add(file_info.Name)
Next file_info
End Sub
Note:
Here you can search files with pattern like:
*.* for search all files
*.js files ends with .js (JavaScript files)
*.vb file ends with .vb (visual basic files
*sys* files which contain text ‘sys’
Download
Download source code for ‘Browsing files in a folder using VB.NET’
Download





Easy and excellent code
Thanks dear Friend