Browse dialog and select multiple files

Hello EE,

I need a browser dialog and the user would be able to select multiples images then on OK press it returns all path of all images selected in a ListBox..

not sure how to create the Dialog with multiple selection

any idea of code?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


    Dim fdlg As New OpenFileDialog
    fdlg.Filter = "(*.dat)|*.dat"
    fdlg.Multiselect = True
    fdlg.CheckFileExists = True
    fdlg.InitialDirectory = Ruta
    If fdlg.ShowDialog(Me) <> Windows.Forms.DialogResult.OK Then Return
    Ruta = Path.GetDirectoryName(fdlg.FileNames(0))

-  Use  Multiselect  propeerty to allow multiple selection.
-  Use FileNames to get an array of strings containing selected files.

- I Also preserve the Path to use it when user uses OpenFileDialog next time.
PhilippeRenaudAuthor Commented:
Ruta ?..

so instead of that I would write like "My documents" ?

and LoadAnalisis would be where I load my listbox?

and fdlg.FileNames is a List(Of String) ??

You can also allow Drop Files fron any File Explorer (Windows Explorer by sample).

Private Sub AnalisisDlg_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
   LoadAnalisis(TryCast(e.Data.GetData(DataFormats.FileDrop), String()))
End Sub

You need set AllowDrop = true on Form or any Control where you want user Drop Files.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

LoadAnalisis is my method to process selected files.

Ruta = Path : I use Spanish name on my private Var I use to Remember last used Path.

fdlg.FileNames - Is array of strings.

PhilippeRenaudAuthor Commented:
very nice..
PhilippeRenaudAuthor Commented:
When i try to drag an item in my documents into my ListView  (allowDrop = true)  I still see the  mouse icon as a "you cant drop"  

I guess im missing something?
You need to catch the dragenter event and allow the drop based on its type
In the drag drop, add this

        If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then
            e.Effect = DragDropEffects.Copy
        End If

Sorry, I miss aditional event:

    Private Sub AnalisisDlg_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
      e.Effect = If(e.Data.GetDataPresent(DataFormats.FileDrop), DragDropEffects.Copy, DragDropEffects.None)
    End Sub
PhilippeRenaudAuthor Commented:
thanks both
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.