I am using sftp to connect to a sftp directory but when passive mode is not selected in filezilla i cannot connect and the same goes for when i attempt my normal code which is as below how would one enable the code for passive mode sftp.
The error that i get is the following says username and password incorrect but i no its not as I can connect in filezilla with passive mode being active.
public void sendFileToSftp(string filename, string serverFile, string IVARef, string firstname,string lastname,string hostname, string port, string username, string password)
{
try
{
// create client, connect and log in
Sftp client = new Sftp();
client.Connect(hostname);
client.Login(username, password);
client.TransferProgressChanged += new EventHandler<SftpTransferProgressChangedEventArgs>(sftp_TransferProgressChanged);
client.ChangeDirectory("/Outbound");
client.CreateDirectory(IVARef + " " + firstname + " " + lastname);
// upload the 'test.zip' file to the current directory at the server
client.PutFile(filename, serverFile);
client.Disconnect();
}
catch (Exception ex)
{
string inner = string.Empty;
if (ex.InnerException != null)
{
inner = ex.InnerException.ToString();
}
// logger.Error("Error in GetNotificationById function aperturenetdal " + ex.ToString() + " " + inner);
return "";
}
}