How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox
How to display folder contents in a listbox How to display folder contents in a listbox
How to display folder contents in a listbox
Go Back  Xtreme Visual Basic Talk > > > How to display folder contents in a listbox


Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2004, 01:29 AM
Ctech Ctech is offline
Newcomer
 
Join Date: Jan 2004
Posts: 15
Unhappy How to display folder contents in a listbox


Hi,

Does anyone know a way to have a list box perminatlty placed on an application form that shows the contents of a specific folder?

I do not wish to use the openfiledialog. I need a more perminant list that only shows filenames.

Hope you can help!!

Cheers.
Reply With Quote
  #2  
Old 01-29-2004, 03:13 AM
Csharp's Avatar
CsharpHow to display folder contents in a listbox Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

to get you started ...
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click '/// you can do this in Form_Load if you choose to. ComboBox1.Items.AddRange(IO.Directory.GetLogicalDrives) '/// add your drives to a combobox End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If Not ComboBox1.SelectedIndex = -1 Then ListBox1.Items.Clear() '/// you could have 2 listboxes here '/// one to hold the folders in the directory , using IO.Directory.GetDirectories(ComboBox1.SelectedItem) '/// then upon clicking the listbox , add the files of that directory to a second listbox. '/// but this is a basic way , just showing how to add the files of a drive letter. ListBox1.Items.AddRange(IO.Directory.GetFiles(ComboBox1.SelectedItem)) End If End Sub
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #3  
Old 01-29-2004, 03:43 AM
Ctech Ctech is offline
Newcomer
 
Join Date: Jan 2004
Posts: 15
Talking

Awsome! Thanks Csharp!

What would be the easiest way just to have the list box preset to show only files in a specific path? E.g c:\windows\*.*

I don't require folders or drives to be altered.

Thanks again!
Reply With Quote
  #4  
Old 01-29-2004, 04:21 AM
Csharp's Avatar
CsharpHow to display folder contents in a listbox Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

like this ....
Code:
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("\System32", "") '/// that gives you the Windows directory , just using Environment.SpecialFolder.System gives the Windows\System32 directory. ListBox1.Items.AddRange(IO.Directory.GetFiles(path))
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #5  
Old 01-29-2004, 05:14 AM
Ctech Ctech is offline
Newcomer
 
Join Date: Jan 2004
Posts: 15
Default

Yes!! I'm nearly there now!

I've been having a fiddle with that code. How do I get it to specify a folder such as c:\test?
Reply With Quote
  #6  
Old 01-29-2004, 06:25 AM
Csharp's Avatar
CsharpHow to display folder contents in a listbox Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

just put c:\test as your path
Code:
ListBox1.Items.AddRange(IO.Directory.GetFiles("c:\test"))
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #7  
Old 01-30-2004, 02:01 AM
Ctech Ctech is offline
Newcomer
 
Join Date: Jan 2004
Posts: 15
Default

Perfect Perfect Perfect!!

Thanks man!
Reply With Quote
  #8  
Old 02-16-2004, 04:13 AM
yulyos yulyos is offline
Freshman
 
Join Date: Feb 2004
Posts: 37
Default

Hi,

I have another way:

Imports System
Imports System.IO

ListBox1.DataSource = Directory.GetFiles("C:\")
__________________
Have a nice day
http://yulyos4vbnet.spaces.live.com
yulyos4vbnet@gmail.com

Last edited by reboot; 02-24-2004 at 04:23 PM.
Reply With Quote
  #9  
Old 01-19-2010, 06:21 PM
techker techker is offline
Newcomer
 
Join Date: Sep 2008
Posts: 3
Default

can you make it list images instead?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
removing a folder via a listbox jpaugh78 General 5 01-04-2004 01:47 AM
Displaying folder contents reticent67 General 3 10-09-2003 10:40 PM
Need help, Fill a drop down menu with contents of a folder GT112 General 4 09-14-2003 04:43 PM
listbox display bscott5 Database and Reporting 1 08-23-2003 10:30 AM
After using (Drive,Dir,File) controls, how to display selected file contents? Juanita General 9 07-09-2002 02:41 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox How to display folder contents in a listbox
How to display folder contents in a listbox
How to display folder contents in a listbox
 
How to display folder contents in a listbox
How to display folder contents in a listbox
 
-->