Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
11.6k views
in General by (260 points)
I have a website publishing application and would like to add the ability to publish to multiple hosts. Is there any problem using the same client object or will I have a memory issue?

foreach( string host in destinationHosts )
         {
            client = new FTPClient( host );
            client.Login(username, password);

            // publish files

            client.Quit();
         }


Thanks for looking!

4 Answers

0 votes
by (161k points)
You can reuse the same FTPClient object - so create it outside the loop.
0 votes
by (260 points)
The object is declared outside the loop but is initialised a number of times inside the loop for each different host... so this is ok to do?
0 votes
by (161k points)
This is fine but you only should need to initialize it once. But no big deal either way.

The object is declared outside the loop but is initialised a number of times inside the loop for each different host... so this is ok to do?
0 votes
by (260 points)
thanks

Categories

...