|
-
Jan 30th, 2003, 05:57 PM
#1
Thread Starter
Hyperactive Member
Get a list of all files in dir
How can I populate a listbox with all the files in a listbox?
-
Jan 30th, 2003, 09:24 PM
#2
I wonder how many charact
VB Code:
' make a reference to a directory
Dim di As New DirectoryInfo("c:\")
Dim diArr As DirectoryInfo() = di.GetDirectories()
Dim diar1 As FileInfo() = di.GetFiles()
' list the names of all the subdirectories in the specified directory
Dim dri As DirectoryInfo
'BeginUpdate method freezes painting while you add items
ListBox1.BeginUpdate()
For Each dri In diArr
ListBox1.Items.Add(dri)
Next
'EndUpdate resumes painting of listbox
ListBox1.EndUpdate()
'list the names of all files in the specified directory
Dim dra As FileInfo
For Each dra In diar1
listbox2.items.add(dra)
Next
Last edited by nemaroller; Jan 31st, 2003 at 10:51 AM.
-
Jan 30th, 2003, 10:32 PM
#3
I wonder how many charact
lol... i just found this stuff I had filed away in my 'common code snippets'
VB Code:
[b]'Adding Files in a directory to a listbox[/b]
ListBox1.DataSource = Directory.GetFiles("C:\")
[b]'Adding subdirectories of a directory to a listbox[/b]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim r As String()
r = Directory.GetDirectories("C:\")
ListBox1.DataSource = r
End Sub
-
Jan 31st, 2003, 05:58 AM
#4
Hyperactive Member
lol... i just found this stuff I had filed away in my 'common code snippets'
Why not include them in the VBCodeBook.NET program to help other users? If you wish to send them, i'll include them in a future release.
-
Jan 31st, 2003, 10:50 AM
#5
I wonder how many charact
Well, consider it submitted
-
Jan 31st, 2003, 11:10 AM
#6
Hyperactive Member
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|