Inserting new files into text box for upload .NET VB2005

Hey Everyone,

I am needing to upload some files to the intranet.  I have a command button with this code below

   Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Dim MyDialog As New OpenFileDialog()
        MyDialog.InitialDirectory = False
        MyDialog.ShowHelp = True
        If MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
        End If
    End Sub

That of course opens up a browser dialog to where the user can select their file or files.  What I need is a textbox below to list the files that they have selected for upload.  The upload button will come later.  My question is what code will I need to get the files to that textbox once they are selected?

Thanks
LVL 1
edfreelsAsked:
Who is Participating?
 
Bob LearnedCommented:
1) If you set MultiSelect = True, then you can select multiple files.

2) The files selected are in the FileNames property for the OpenFileDialog

3) After the ShowDialog, you can determine if there was a click on <Ok> button.

    Dim MyDialog As New OpenFileDialog()

    MyDialog.InitialDirectory = False
    MyDialog.ShowHelp = True
    MyDialog.ShowReadOnly = False
    MyDialog.Multiselect = True
    If MyDialog.ShowDialog() = DialogResult.OK Then
      For Each fileName As String In MyDialog.FileNames
        Me.TextBox1.AppendText(fileName & vbCrLf)
      Next
    End If

Bob
0
 
edfreelsAuthor Commented:
Very Nice, works perfect.  Going to ask another question that has to do with this, but I will award seperate points.  Be on the lookout learned one, lol.
0
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.

All Courses

From novice to tech pro — start learning today.