Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.3k views
in .NET FTP by (120 points)
Hello all.

I am writing a small ftp program to up- and download some files from a specified server. The user can put the server adress and username/password in textboxes. Now I am searching for a way to create my own error messages when there is a error with the connection (sample: username or password not correct, server not existing ...).

I used this small example code:
Try
   Dim files As Array
   FtpConnection1.Connect()
   files = FtpConnection1.GetFiles()
   ListBox1.Items.AddRange(files)
   FtpConnection1.Close()

   Catch ex As Exception
   If FtpConnection1.IsConnected Then
      FtpConnection1.Close()
   End If
   MessageBox.Show(Me, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

If there is a error I get a standard error message from the program but I want to get a error code to create my own error message.

So the question is: How can I get the error code when there is an error or exception?

Thanks.

1 Answer

0 votes
by (162k points)
Take a look at the error code that is in the exception. Unfortunately FTP servers aren't very consistent in their use of error codes, but if you are dealing with only one server you should be able to display some sensible messages.

Categories

...