Is it possible to store an resuse a FTP session?

Advertisement

Nive
Guest

Is it possible to store an resuse a FTP session?

Hi,

We have been using WinSCP in our project for a few years now. What we used to do was, create a session and dispose it every time we had to connect to one of our ftps. But, now that we are expanding massively we want to stop accessing our FTP server every few seconds.

Instead, we'd like to manage several several sessions for each ftp we are accessing, and re-use the same session without closing/disposing it until it timeouts.

I've tried to implement this but, every time i open a session and try to access it again without closing it, the Opened variable throws an InvalidOperationException error.

Is it possible to do this? Or is there any workarounds to solve this?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
33,710
Location:
Prague, Czechia

Re: Is it possible to store an resuse a FTP session?

Session.Open throws InvalidOperationException only if you called Session.Dispose before:
https://winscp.net/eng/docs/library_session_dispose

If you want to reuse the session, do not close it! Note that Session.Dispose is called implicitly at the end of the using block.

Reply with quote

Advertisement

You can post new topics in this forum