DijitalAddict
MIS
I am very new at VB (3 days).
I have a form which has a dropdown box (comboDrives)that list the drives on the computer. Then a ListBox (lbFiles)that displays the files in the selected drive. I also have 2 radio buttons (rb8000, rb9000)for the user to select a folder to copy that file to. What I want to do is copy the file(s) they select to the folder they select.
I keep getting the error:
"An unhandled exception of type 'System.InvalidCastException' occurred in system.windows.forms.dll
Additional information: Cast from type 'FileInfo' to type 'String' is not valid."
My Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim x
x = lbFiles.SelectedItem
If rb8000.Checked = True Then
System.IO.File.Copy(x, "C:\Program Files\CheckPrint\Troy_8000\*.*")
Else
If rb9000.Checked = True Then
System.IO.File.Copy(x, "C:\Program Files\CheckPrint\HP_9000\*.*")
Else
MsgBox("You need to select a printer.", MsgBoxStyle.OKOnly)
End If
End If
End Sub
I have a form which has a dropdown box (comboDrives)that list the drives on the computer. Then a ListBox (lbFiles)that displays the files in the selected drive. I also have 2 radio buttons (rb8000, rb9000)for the user to select a folder to copy that file to. What I want to do is copy the file(s) they select to the folder they select.
I keep getting the error:
"An unhandled exception of type 'System.InvalidCastException' occurred in system.windows.forms.dll
Additional information: Cast from type 'FileInfo' to type 'String' is not valid."
My Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim x
x = lbFiles.SelectedItem
If rb8000.Checked = True Then
System.IO.File.Copy(x, "C:\Program Files\CheckPrint\Troy_8000\*.*")
Else
If rb9000.Checked = True Then
System.IO.File.Copy(x, "C:\Program Files\CheckPrint\HP_9000\*.*")
Else
MsgBox("You need to select a printer.", MsgBoxStyle.OKOnly)
End If
End If
End Sub