1,105,423 Community Members

Filling listbox with files in a directory

Member Avatar
linux
Posting Shark
936 posts since Aug 2006
Reputation Points: 107 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

I want to add a list box onto a form, and have it (once the form loads), it'll list all of the files in C:\WINDOWS\ . Is there any easy way to accomplish this?

Member Avatar
dmf1978
Junior Poster in Training
51 posts since Aug 2006
Reputation Points: 8 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
Try this

Dim folderInfo As New IO.DirectoryInfo("c:\windows")
        Dim arrFilesInFolder() As IO.FileInfo
        Dim fileInFolder As IO.FileInfo

        arrFilesInFolder = folderInfo.GetFiles("*.*")
        For Each fileInFolder In arrFilesInFolder
            ListBox1.Items.Add(fileInFolder.Name)
        Next

Hope it helps

Member Avatar
linux
Posting Shark
936 posts since Aug 2006
Reputation Points: 107 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks. That worked nicely.

Can you also help me with how to make a progressbar that would update with a timer, thatd do 1% every .5 seconds? Also when the form loads.

Member Avatar
linux
Posting Shark
936 posts since Aug 2006
Reputation Points: 107 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

Never mind, I figured it out! :D

Question Answered as of 5 Years Ago by dmf1978
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article