943,587 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 7109
  • VB.NET RSS
Jul 22nd, 2008
0

Filling listbox with files in a directory

Expand Post »
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?
Reputation Points: 118
Solved Threads: 30
Posting Shark
linux is offline Offline
931 posts
since Aug 2006
Jul 22nd, 2008
0

Re: Filling listbox with files in a directory

Hi,
Try this
VBNET Syntax (Toggle Plain Text)
  1. Dim folderInfo As New IO.DirectoryInfo("c:\windows")
  2. Dim arrFilesInFolder() As IO.FileInfo
  3. Dim fileInFolder As IO.FileInfo
  4.  
  5. arrFilesInFolder = folderInfo.GetFiles("*.*")
  6. For Each fileInFolder In arrFilesInFolder
  7. ListBox1.Items.Add(fileInFolder.Name)
  8. Next
Hope it helps
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 22nd, 2008
0

Re: Filling listbox with files in a directory

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.
Reputation Points: 118
Solved Threads: 30
Posting Shark
linux is offline Offline
931 posts
since Aug 2006
Jul 22nd, 2008
0

Re: Filling listbox with files in a directory

Never mind, I figured it out!
Reputation Points: 118
Solved Threads: 30
Posting Shark
linux is offline Offline
931 posts
since Aug 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: USB driver files
Next Thread in VB.NET Forum Timeline: video captions in vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC