I have a folder path which i chose at runtime. Now i want to check if the Folder contains files with extension .txt. How to do this.

Try this:

Imports System
Imports System.IO

Public Class Form1
    Dim fi As FileInfo()
    Dim di As DirectoryInfo

    Private Sub GetFiles(ByVal Path As String, ByVal Filter As String)
        di = New DirectoryInfo(Path)
        fi = di.GetFiles(Filter)
        For Each File As FileInfo In fi
            MessageBox.Show(File.Name)
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetFiles("d:\banner\", "*.txt")
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.