0 votes

After Close with client.close of an ipen FTP-Connection I get an error:

System.ObjectDisposedException: Auf das verworfene Objekt kann nicht zugegriffen werden.
Objektname: "ClientBase".

Before I made
1.) client.close
2.) client.abort
3.) client.dispose

What should I make, to get after a close a new connection with ftp.dll opened?

by (300 points)
edited by

1 Answer

0 votes

For every connection you should use Close and Dispose sequence, as in the example below:

using(Ftp ftp = new Ftp())
{
    ftp.ConnectSSL("ftp.server.com");  // or ConnectSSL for SSL
    ftp.Login("user", "password");

    ftp.ChangeFolder("uploads");
    ftp.Upload("report.txt", @"c:\report.txt");

    ftp.Close();
}

As documentation states: Close sends QUIT command and releases all resources acquired by this object.

You can't use Ftp instance after Close is called.

To establish a new connection you need to create a new Ftp class instance.

by (301k points)
...