How do I fill a listbox with the names of the folders in a folder i.e
C:\Folder_1\Folder_First
C:\Folder_1\Folder_Second
C:\Folder_1\Folder_Third
Listbox shows the folder Names
Folder_First
Folder_Second
Folder_Third
ListboxFill with Folder Names
Page 1 of 1
4 Replies - 7165 Views - Last Post: 08 September 2006 - 04:47 AM
Replies To: Listbox
#2
Re: Listbox
Posted 26 August 2006 - 11:16 AM
You will want to use the DirectoryInfo.GetDirectories methods.
Here is the MSDN showing how.
Here is the MSDN showing how.
This post has been edited by jayman9: 26 August 2006 - 12:55 PM
#3
Re: Listbox
Posted 28 August 2006 - 08:23 AM
Tested and approved:
This returns directories and files.
using System.IO;
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(""));
dlFiles.DataSource = dirInfo.GetFileSystemInfos();
dlFiles.DataBind();
This returns directories and files.
#4
Re: Listbox
Posted 08 September 2006 - 12:09 AM
Imports System.IO
Dim info As DirectoryInfo = New DirectoryInfo("C:\Folder_1")
ListBox1.DataSource =info.GetFileSystemInfos()
ListBox1.DataBind()
Dim info As DirectoryInfo = New DirectoryInfo("C:\Folder_1")
ListBox1.DataSource =info.GetFileSystemInfos()
ListBox1.DataBind()
#5
Re: Listbox
Posted 08 September 2006 - 04:47 AM
Here's what worked for me.
Private Sub frmOptions_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim theFolders() As String
theFolders = Directory.GetDirectories("C:\MainFolder\")
For Each currentFolder As String In theFolders
Me.lstTheme.Items.Add(currentFolder.Substring(currentFolder.LastIndexOf("\") + 1))
Next
End Sub
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|