warren1369

ok so obviously im a newb so sorry if this is a simple question here is what I would like to be able to do in vb2005 express

I want to be able to select a file (photo) and or multiple files(photos) with the open file dialog then I want to take those file names and list them in listview

when I select the file in list view it will display in a picture box thats not a problem I have sample code to make that work but I want to give some info on what I am doing it may help for a solution.




Re: Visual Basic Express Edition how do I use openfile dialog filenames to listview

DMan1

Code Snippet

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ofd As New OpenFileDialog

With ofd

.Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg Files (*.jpg)|*.*"

.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)

.Multiselect = True

If .ShowDialog() = Windows.Forms.DialogResult.OK Then

If .FileNames.Length > 0 Then

For Each s As String In .FileNames

Me.ListView1.Items.Add(s)

Next

Else

If Not String.IsNullOrEmpty(.FileName) Then

Me.ListView1.Items.Add(.FileName)

End If

End If

End If

End With

End Sub






Re: Visual Basic Express Edition how do I use openfile dialog filenames to listview

warren1369

Using the above code works like a charm but it will list the full path to the file what should I try to do to make the list only display the file names



Re: Visual Basic Express Edition how do I use openfile dialog filenames to listview

DMan1

Code Snippet

For Each s As String In .FileNames

Dim Fi As New IO.FileInfo(s)

Me.ListView1.Items.Add(Fi.Name)

Next