0 votes
by (330 points)
edited

Hi, Can the Rebex.NET.FTP able to connect to the FTP server using Active mode?

It works great when connecting to a ftp server which is running in passive mode. But it can't get directory listing using passive mode.

I have a microsoft windows 2008 server running Filezilla FTP server and using an public IP address but protected by MIcrosoft Firewall. It can only operate in Active mode.

my coding is as follows:

        string FTPServer = getFTPServer(SiteCode);
        string FTPUser = getFTPuser(SiteCode);
        string FTPPass = getFTPpass(SiteCode);

        Ftp client = new Ftp();

        client.TransferMode = FtpTransferMode.Stream;
        client.Connect(FTPServer);
        client.Login(FTPUser, FTPPass);

        string pathstr = Server.MapPath("/GlobalFiles");

        pathstr = pathstr + "\\*";

        client.PutFiles(@pathstr, "/", FtpBatchTransferOptions.Recursive, FtpActionOnExistingFiles.OverwriteOlder);

Many thanks, Eddie

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (148k points)
edited
 
Best answer

Yes, Rebex FTP supports active mode. However, in order to use it, you have to disable passive mode:

    ...

    Ftp client = new Ftp();

    // instruct the Ftp object to use active mode
    client.Passive = false; // <-- add this line

    client.TransferMode = FtpTransferMode.Stream;
    client.Connect(FTPServer);
    client.Login(FTPUser, FTPPass);

    ...
...