Question:

Visual Basic 2008 & Open file

by  |  earlier

0 LIKES UnLike

I am trying to have Visual Basic 2008 show an open file dialog box, find an MP3 file and put the file location (C:\Documents\Music\Mymp3.mp3) into a variable string. I will then use that variable string for other things, but How do I get this to work?

 Tags:

   Report

1 ANSWERS


  1. Hello! To start off, you need to show the dialog box.

    FileDialog.ShowDialog()

    In the same routine, you will handle the collection of filenames that the user has selected in the file dialog. If the user can only select a single file, you can store the filename (which includes the path) in this way:

    Dim fsFile As String = FileDialog.FileName

    If your file dialog would allow the user to select multiple files, you could use:

    Dim fsFiles As String() = FileDialog.FileNames

    and then handle each individual file within the collection with a control structure in this way:

    For Each fsFile In fsFiles

    'Each fsFile contains a filename and path

    End For

    Hope this helps.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.