Simple Way to Get All .txt Files in the Directory Using VB.Net
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.
Open Microsoft Visual Studio 2015 and create a new windows form application in visual basic.
Do the Form just like shown below.
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")
- For Each txt_file As FileInfo In txtFiles
- 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.