Here's my code:
SSHNet.PasswordConnectionInfo connInfo = new SHNet.PasswordConnectionInfo(xxxxxxxxxxx);
using (var client = new SSHNet.SftpClient(connInfo))
{
client.Connect();
if (client.IsConnected)
{
using (Stream fileStream = EncryptionUtilities.DecryptFile(path))
{
client.UploadFile(fileStream, path);
fileStream.Flush();
fileStream.Close();
fileStream.Dispose();
}
}
client.Disconnect();
}
Any suggestions highly appreciated.
Comments: ** Comment from web user: avidyarthi **
public void SendFiles()
{
string path = @"C:\Projects\abc.csv";
SSHNet.PasswordConnectionInfo connInfo = new SSHNet.PasswordConnectionInfo(SFTPRequest.SFTP_Host,
SFTPRequest.SFTP_Port, SFTPRequest.SFTP_UserName, SFTPRequest.SFTP_Password);
using (var client = new SSHNet.SftpClient(connInfo))
{
foreach (var d in connInfo.Encryptions.Where(p => p.Key != "aes128-cbc").ToList()) { connInfo.Encryptions.Remove(d.Key); }
client.Connect();
if (client.IsConnected)
{
using (Stream fileStream = EncryptionUtilities.DecryptFile(path))
{
client.UploadFile(fileStream, "abc.csv"), false, null);
fileStream.Flush();
fileStream.Close();
fileStream.Dispose();
}
}
client.Disconnect();
}
}