This project is read-only.

FtpException not thrown on login errors

Nov 27, 2010 at 1:42 PM

I am not sure if this is a feature or not, but when login parameters (username or password) are incorrect, an exception of class System.Exception is raised with message "Unknown error (0x2eee)". Altough it's not a problem, shouldn't it be catched internally by the lib and rethrown as FtpException?

Nov 29, 2010 at 1:53 PM
Edited Nov 29, 2010 at 2:02 PM

I have the same error at "FtpFileInfo[] fi = ftp.GetFiles();"

Unknown error (0x2efd)

Dec 6, 2010 at 6:25 PM

The best thing to do is to change the FtpConnection.Error() method so that any error greater than ERROR_INTERNET_EXTENDED_ERROR just returns the last response information from the FTP server:


        private void Error()
            int code = Marshal.GetLastWin32Error();

                string errorText = InternetLastResponseInfo(ref code);
                throw new FtpException(code, errorText);
                throw new Win32Exception(code);

Feb 22, 2011 at 5:03 PM

I resolved with this code.


using (FtpConnection ftpConnection = new FtpConnection("server", "usr", "pwd")) {
 try {
 } catch (FtpException ex) {
 } catch (Win32Exception exW32) {
  MessageBox.Show("Error en autentificación, verifique los errores de conexion");