I am writing a program and want to have a a file loaded to be written to a specific location on the drive when an option is selected in a combobox. Here is the code that I have:

Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged
        If ComboBox2.Text = "option" Then
            ComboBox5.Items.Add("File")
            If ComboBox5.Text = "File" Then
               loadfile.reasources.ep3()
            End If
        End If
    End Sub
End Class

Do you mean you want to copy a file? Or you want to create a new file?
What do you mean to load a file to a specific location?

I am writing software to open a .bin file from a computer and write it to an external location (ie. via com1 or usb). To start things off I am just trying to get my program to load in the background a specific .bin file when a combobox option is selected. Then when a submit button is pressed the file is written to the external location. I hope I explained that simply.

So you want to copy the file. Here is your code. When you choose from combobx the file option, then you should dim the source file path and destination path. When you press submit button, you should just copy the file

Dim FileToCopy As String = "C:\test.bin"
Dim NewCopy As String = "D:\NewTest.bin"

If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
MsgBox("File Copied")
End If

thank you. I will try that right away. results soon to follow :\

so for each "IF" statement I would put the dim statement as well for each combobox option, so that when the submit button is pressed the "FileToCopy" is the one that goes along with the combobox option?

so for each "IF" statement I would put the dim statement as well for each combobox option, so that when the submit button is pressed the "FileToCopy" is the one that goes along with the combobox option?

I sent you the solution. Please do something on your own. Be creative.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.