Command Button Upload Code

I have the following code for a command button.  As you can see when executed you are able to choose files.  Then the file path drops down in the textbox.  I need to know what code to put in for another command button that would upload these files.    

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        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.TextBox4.AppendText(fileName & vbCrLf)
        End If
    End Sub

Who is Participating?
Jens FiedererTest Developer/ValidatorCommented:
Assuming you REALLY want a path like
when the NodeID is 13
all you need to do is append
to the Value of ListBox1
and you have a valid filename.
Jens FiedererTest Developer/ValidatorCommented:
What mechanism do you mean to use to "upload", and where to?

Obviously you can upload only to computers that provide some facility to DO this, and there many possibilities (ftp, web services, copying using UNC paths, etc.).
edfreelsAuthor Commented:
ah sorry,

Should have specified.  Using VB2005 and uploading to the intranet.  My upload string needs to be something like this \\fileserver1\intranet\marketing\st<nodeid)
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jens FiedererTest Developer/ValidatorCommented:
In that case, your command handler for the new button should be able to do its job with just File.Copy!

You might have some issues with permissions to the target machine, but if not this should be easy.
edfreelsAuthor Commented:

Yea I have this code below, but I am having trouble figuring out the last part

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Dim destinationFolder As String = "\\fileserver1\wilcointranet\marketingpromotion\st[NodeID]"

        Dim files As String() = Me.TextBox5.Text.Split(vbCrLf)
        For Each file As String In files
            'Remove unwanted character
            file = file.Replace(Chr(10), "")

            If file.Trim() <> "" Then
                'copy file
                My.Computer.FileSystem.CopyFile(file, _
                    IO.Path.Combine(destinationFolder, IO.Path.GetFileName(file)), _
            End If

        MsgBox("Upload Complete!")
    End Sub

In the destination folder where you see st[nodeid]  I am not sure what to change that to, to get it to automatically query the nodeid.  Here is the code on my listbox.

  Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim connectionString As String = _
 "Data Source=WHSQL2K301;Initial Catalog=WilcoIntranet;Persist Security Info=True;User ID=coldfusion;Password=coldfusion;"

        Dim cn As New SqlClient.SqlConnection(connectionString)
        Dim da As New SqlClient.SqlDataAdapter()
        da.SelectCommand = New SqlClient.SqlCommand()
        With da.SelectCommand
            .Connection = cn
            .CommandType = CommandType.Text

            'You need to change the CommandText Select Statement
            '    Change "NodeID" to the nodeID column name
            '    Change "StoreName " to the nodeID column name
            '    Change "StoresTable " to the name of the table in your database  
            .CommandText = _
                "SELECT NodeID, NodeNbr FROM Node ORDER BY NodeName"
        End With

        Me.ListBox1.DisplayMember = "NodeName"
        Me.ListBox1.ValueMember = "NodeID"
    End Sub

Have any ideas?

Jens FiedererTest Developer/ValidatorCommented:
Quite a jump from "upload" to SQL!

Anyway, one thing that I can tell you for certain is that you cannot use
     Me.ListBox1.DisplayMember = "NodeName"
when you don't pull NodeName in your SELECT!

What happens if you use
.CommandText = _
                "SELECT NodeID, NodeName FROM Node ORDER BY NodeName"
edfreelsAuthor Commented:
ok,  I will put that in, what do I need to do after that"?
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.