try this. you'll have to modify it if you're getting many files from different directories.
vb Code:
Public Class Form1 Dim files() As String = IO.Directory.GetFiles("c:\windows") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For x As Integer = 0 To files.GetUpperBound(0) ListBox1.Items.Add(IO.Path.GetFileName(files(x))) Next End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged MsgBox(files(ListBox1.SelectedIndex)) End Sub End Class




Reply With Quote