Filling listbox with files in a directory

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2006
Posts: 917
Reputation: linux is an unknown quantity at this point 
Solved Threads: 27
linux's Avatar
linux linux is offline Offline
Posting Shark

Filling listbox with files in a directory

 
0
  #1
Jul 22nd, 2008
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?
Toshiba M1151.49 GB DDR-2 RAM1.6 GHz Centrino Duo80GB HDDWindows XP Media Center Edition
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Filling listbox with files in a directory

 
0
  #2
Jul 22nd, 2008
Hi,
Try this
  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
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 917
Reputation: linux is an unknown quantity at this point 
Solved Threads: 27
linux's Avatar
linux linux is offline Offline
Posting Shark

Re: Filling listbox with files in a directory

 
0
  #3
Jul 22nd, 2008
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.
Toshiba M1151.49 GB DDR-2 RAM1.6 GHz Centrino Duo80GB HDDWindows XP Media Center Edition
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 917
Reputation: linux is an unknown quantity at this point 
Solved Threads: 27
linux's Avatar
linux linux is offline Offline
Posting Shark

Re: Filling listbox with files in a directory

 
0
  #4
Jul 22nd, 2008
Never mind, I figured it out!
Toshiba M1151.49 GB DDR-2 RAM1.6 GHz Centrino Duo80GB HDDWindows XP Media Center Edition
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC