Inserting new files into text box for upload .NET VB2005

Posted on 2007-07-31
Last Modified: 2013-11-07
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?

Question by:edfreels
    LVL 96

    Accepted Solution

    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)
        End If

    LVL 1

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now