Files-listbox

  • Thread starter Thread starter Niels
  • Start date Start date
N

Niels

Hello,

I have a lisbox placed on a form, in the listbox i want to
get the filenames of a specific directory.

So if i have 3 files in directory "c:\Test", i want to be
able to select them in the listbox.

I think I have to count the number of files in the
directory, and then per file adding them as item...

Well it's just simple mindspinning of me, but i haven't
got a clue how to get it working...

Can anyone help me please....
 
-----Original Message-----
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemiodirectoryinfoclasstopic.asp

And to

(Addrange)

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectio
nclasstopic.asp

It should be very simple with this information.

I hope this helps?

Cor


.
Thanks for your reaction, but it is not so very simple for
a beginner...

I watched the code, and got a few lines of code working

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MyPath = Application.StartupPath
Dim Dirs As DirectoryInfo = New DirectoryInfo
(MyPath & "\Stamps\")
Dim FileCount As FileSystemInfo() =
Dirs.GetFiles
Dim Count As Integer
Count = FileCount.Length - 1

Dim ItemObject(Count) As System.Object
Dim i As Integer
For i = 0 To Count
ItemObject(i) = FileName ' "FullName" geeft
het path: "Name" geeft directorynaam
Next i
ComboBox1.Items.AddRange(ItemObject)
End Sub


But this code gives the path instead of the filenames..

Can anyone help me again please...
 
Back
Top