I am trying to do a simple download of some files from an FTP server. I am using the .NET Assembly that WinSCP provides. The source FTP server has a setting that does not allow more than 3 sessions, so I need to disconnect once the files are downloaded. I am able to connect to the server, because every time I try to run the program 4 times, it disallows the session.open saying that the max sessions allowed is 3. Then I have to reboot the machine to end the sessions.
http://winscp.net/eng/docs/library_session_close
Am I doing something incorrectly? At this point I'm just trying to get the Connect and the Disconnect portion to work. I'm kinda new to this and would appreciate your help.
using System;
using WinSCP;
class FTPDownload2
{
public static void Main()
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "name",
UserName = "uname",
Password = "pwd!"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
session.Close();
}
}
}