Nick Dudar
Automation Guru
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
100 XP
In this tutorial I’m going to teach you how to get all .txt Files in the Directory Using VB.Net. This method will surely help you to retrieve all .txt file in a specific directory and display it inside the listbox. This simple program can be easily done in no time. See the procedure below to find out how it works.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application in visual basic.
Step 2
Do the Form just like shown below.
Step 3
Double click the form to fire the click event handler
of it and do the following code for getting all .txt file in a certain directory when the button is clicked.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application in visual basic.

Step 2
Do the Form just like shown below.

Step 3
Double click the form to fire the click event handler
of it and do the following code for getting all .txt file in a certain directory when the button is clicked.
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- Dim
folderBrowseDialog As
FolderBrowserDialog = New
FolderBrowserDialog()
- folderBrowseDialog.SelectedPath = "C:\"
- Dim
driNFO As
New
DirectoryInfo(folderBrowseDialog.SelectedPath)
- Dim
txtFiles As
FileInfo() = driNFO.GetFiles("*.txt"
)
- ListBox1.Items.Clear()
- For
Each
txt_file As
FileInfo In
txtFiles
- ListBox1.Items.Add(txt_file.Name)
- Next
- End
Sub
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.