When users put in their user information I want to be able to verify that it is correct by checking to see if they are connected. If they are not connected I want it to open a message box and skip to the end of the routine. If it is connected I want it open another message box confirming it and continue to download the file. If for some reason the file does not exist or you lose connection it want it to open another message box that indicates that. When I use the code below and the user information is incorrect, it goes to the last exception and does not open the message box pertaining to the incorrect user information. Can someone please help!!!!
P.S. I am using the free version.
Try
FtpConnection1.ServerAddress = (M_Server.Text)
FtpConnection1.UserName = (M_UserName.Text)
FtpConnection1.Password = (M_Password.Text)
FtpConnection1.Connect()
If FtpConnection1.IsConnected = False Then
MsgBox("Please check your user name and password.", MsgBoxStyle.Critical, "Connection Error!")
GoTo notconnected
Else : MsgBox("You are connected.", MsgBoxStyle.Critical, "Connected")
End If
FtpConnection1.ChangeWorkingDirectory("/var/tmp")
Dim file_1 As String = M_UserName.Text & ".txt"
Dim path As String = "C:\test\"
FtpConnection1.DownloadFile(path + file_1, file_1)
FtpConnection1.Close()
Catch ex As Exception
MsgBox("Please check your network connection and make" & vbNewLine & "sure you have saved your file to the L1 printer.", MsgBoxStyle.Critical, "Connection/File Error!")
End Try
notconnected:
End Sub