Inserting new files into text box for upload .NET VB2005

Posted on 2007-07-31
Medium Priority
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

Bob Learned earned 2000 total points
ID: 19602885
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


Author Comment

ID: 19602987
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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month17 days, 9 hours left to enroll

830 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