Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
in FAQ: edtFTPnet/PRO by (120 points)
We used be able to do the following in an FTPClient derived class in version (2.2.1)
        Evaluating FTPnet/Pro for possible upgrade and want to have this functionality. Please help.

        public Stream OpenRead(String directory, String filename)
            // Get an input stream to read data from
            BufferedStream inputStream = null;
            TransferType = FTPTransferType.BINARY;
            inputStream = new BufferedStream(data.DataStream);
            return (inputStream);
by (2.7k points)
What happens now?
by (120 points)
Thanks for responding. Right now,  it seems InitGet method or equivalent is not available in FtpClient.
So it won't even compile with the following lines in code.
            inputStream = new BufferedStream(data.DataStream);

Is there any way to open and get hold of the stream in an FtpClient derived class? i.e. replace these two lines in above OpenRead method.

Here is a sample test snippet on OpenRead call.
            IFtpClient ftp = new MyFtpClient(ftpAddress, credentials, false);
            ftp.Connect(); //this suceeds
      MyIOStreamWrapper streamWrapper = new MyIOStreamWrapper();
           streamWrapper.InputStream = ftp.OpenRead(inputDir, inputFile);
by (2.7k points)
I just checked our repository and noticed that FTPClient.InitGet was private in version 2.2.1, so how did you manage to call it from a subclass?  Perhaps you modified the source yourself?

Have you considered using FTPClient.Get(Stream, string)?
by (120 points)
InitGet was changed to protected. Is it still around in the latest pro source code? Need to confirm during evaluation process (to justify purchase).
Did look into FTPClient.Get and got an impression that it would not return without downloading file (or perhaps a block). We need to get the Stream *before* the transfer actually takes place.
by (2.7k points)
Yes, InitGet is still around.

Regarding the stream, if MyIOStreamWrapper extends Stream and you pass an instance of it into FTPClient.Get(Stream,string) then can't you place any code that you need executed before downloading begins into your MyIOStreamWrapper.Read method?

By the way, System.ServiceModel.Channels.DelegatingStream could be a useful super-class for your stream class.  It allows you to add functionality to an existing Stream subclass (such as FileStream) without having to duplicate all of the functions.
by (120 points)
That is helpful. If FTPClient's stream is accessible immediately after InitGet (i.e. before download starts) it should be good.  It seems like source is needed. One more question. Would Secure FTP work with the same code base (i.e. Just need to change the name of the class and specify ssl)? Thanks.
by (2.7k points)
The FTPS client (SSLFTPClient) extends FTPClient, so you should be able to do it the same way there, but SFTP is a completely different protocol, so SSHFTPClient doesn't extend FTPClient.

Please log in or register to answer this question.