Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filenames in Listbox

Status
Not open for further replies.

Frihi

Programmer
Jun 24, 2001
48
CH
I use this code to show only files with a certain extension in a Listbox.

Dim files() As String = IO.Directory.GetFiles("c:\MyApp", "*.swf")
Dim file As String
For Each file In files
Me.ListBox1.Items.Add(file)
Next

This gives me the Files shown as:

C:\MyApp\myFile1.swf
C:\MyApp\myFile2.swf
...

But now I want to edit only the filenames, without Path and extension, like:

MyFile1
MyFile2
...

Can anyone give me a hint?
 
Thank you. Meanwhile I've made it like that:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim files() As String = IO.Directory.GetFiles("c:\Path", "*.swf")
Dim file As String
For Each file In files
Me.ListBox2.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
Me.ListBox1.Items.Add(file)
Next
End Sub


Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Flash1.LoadMovie(0, Me.ListBox2.SelectedItem)
End Sub

Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
Me.ListBox1.SelectedIndex = Me.ListBox2.SelectedIndex
End Sub

I had to put 2 Listboxes, 1 to be able to display the names without extensions and the other to select the movies. Now I'm trying to make it with only one Box but I'm kind of stucked on it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top