Reading Files in a Folder

I have 'combobox1 inside my 'groupbox1'

I also have a couple of documents in a folder on my desktop called 'docs'

What code do i put in so the combobox lists all the docs that are in the 'docs' folder


Answer this question

Reading Files in a Folder

  • Adam Smith MS

    i put this in the combobox1 code and it said 'path' could not be declared'

    what does that mean

  • Ben Christian

    no...

  • Jeff Bevans

    Did you import the System.IO namespace

  • SabariRajan



    Imports System.IO

    Dim desktopDir As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    Dim dirName As String = Path.Combine(desktopDir, "docs")
    Dim dir As New DirectoryInfo(dirName)
    For Each file As FileInfo In dir.GetFiles("*.doc")
        comboBox.Items.Add(file.FullName)
    Next

     


  • Reading Files in a Folder