Populating a CheckedListBox from a directory

bjwade62

Well-known member
Joined
May 25, 2006
Messages
50
Programming Experience
3-5
Does anyone know how to populate a CheckedListBox from a directory?
 
Presuming that you mean populate a CheckedListBox with the files that are found in a directory, you could try the following:

VB.NET:
Dim strBasePath As String = "C:\"
        Dim dirInputFileInfo As IO.FileInfo
        Dim dirInputInfo As New IO.DirectoryInfo(strBasePath)
        Dim dirInputFileArray As IO.FileInfo() = dirInputInfo.GetFiles()

        For Each dirInputFileInfo In dirInputFileArray
            Me.CheckedListBox1.Items.Add(dirInputFileInfo.Name) 
        Next
 
Back
Top