Hi,
When GetDownloadStream
method has been called, most methods on that Ftp
instance will fail with "Another operation is pending" error. FTP is a single-operation protocol, and until the stream has been closed, no other FTP operations are allowed, and that includes the QUIT command (represented by the Disconnect
method).
For example, the following code would fail:
Ftp client = new Ftp();
client.Connect("test.rebex.net", 21);
client.Login("demo", "password");
var stream = client.GetDownloadStream("/pub/example/WinFormClient.png");
client.Disconnect();
In your sample code above, you do actually close the responseStream
(via using
block), so Disconnect
should work as well. It would be a bug if it failed despite the stream having been closed.
However, we have not been able to reproduce the bug - if we change your code to download a file from one of our servers, it works fine.
Are you able to reproduce the issue using your code with test.rebex.net
server (see the code snippet above) and /pub/example/WinFormClient.png
file?
Also, please enable logging to see what is actually going on when the error occurs. To create a debug log, just add the following line to your code:
client.LogWriter = new Rebex.FileLogWriter("ftplog.txt", Rebex.LogLevel.Debug);
If needed, please post the content of ftplog.txt here or mail it to support@rebex.net for analysis.