Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.8k views
in .NET FTP by
I have tried to setup a BytesTransferred event as follows:

   public class Ftp : FTPClient {
      
      public Ftp() {         
         RemoteHost = RegistryKeys.ftpServer;   
         this.BytesTransferred += new BytesTransferredHandler(Ftp_BytesTransferred2);
         Connect();
         User(RegistryKeys.ftpLogin);
         Password(RegistryKeys.ftpLoginPassword);
         TransferType = FTPTransferType.BINARY;
         ChDir(RegistryKeys.ftpFolderName);
         this.BytesTransferred += new BytesTransferredHandler(Ftp_BytesTransferred);
      }

      public void resetDirectory() {
         ChDir("");
         ChDir(RegistryKeys.ftpFolderName);
      }

      private void Ftp_BytesTransferred(object ftpClient, BytesTransferredEventArgs bytesTransferred) {
         Console.Write("Yes!");
      }

      private void Ftp_BytesTransferred2(object ftpClient, BytesTransferredEventArgs bytesTransferred) {
         Console.Write("Yes!");
      }
   }


This is my own little FTP class I use just so I can initiate the connect how I'd like, etc.

Anyway, I've stepped through everything, and the event just isn't firing. I am using the Put() method while looping through a list of files, but I get no event firing.

Any thoughts?

1 Answer

0 votes
by (161k points)
They are not declared as virtual in FTPClient - I've read somewhere (?) that if events aren't virtual, subclasses can't register them.

You could try changing them to virtual in the code and recompile the DLL to see if this works.

I have tried to setup a BytesTransferred event as follows:

This is my own little FTP class I use just so I can initiate the connect how I'd like, etc.

Anyway, I've stepped through everything, and the event just isn't firing. I am using the Put() method while looping through a list of files, but I get no event firing.

Any thoughts?

Categories

...