Hi Alls,

Really need your help.
I'm trying to list all text file in Application Startup path folder in combobox but cannot...can anyone help?.....In Application Startup Path folder i got more than 3 .txt file. So i want to list out in combobox...please help me..thank you

here try this:

Imports System.IO
Imports System.IO.Path
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strPath As String = System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\"

        Dim dirInfo As New IO.DirectoryInfo(strPath)

        For Each file As FileInfo In dirInfo.GetFiles("*.txt", SearchOption.TopDirectoryOnly)

    End Sub
End Class
Attachments temp.PNG 10.96 KB

This might help also. Just change the ListBox to a ComboBox.

Dim myCoolFolder As String = "C:\!vbTemp\" '// your folder.

        For Each myCoolFile As String In My.Computer.FileSystem.GetFiles _
                                                    (myCoolFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.*")
            ListBox1.Items.Add(IO.Path.GetFileName(myCoolFile)) '// add file name with extension.

        '// to search subfolders, change "SearchTopLevelOnly" to "SearchAllSubDirectories".
        '// to only get a certain file type, change "*.*" to your file type.
        '//-- example for .txt files: "*.txt"

Since you cannot receive private messages, I'll post here and remind you to not forget to mark the thread solved if Solved. And of course, glad I could help. :)

This article has been dead for over six months. Start a new discussion instead.