public static void UploadFile(string localFileToUpload, string host, string targetFile, string userName, string password) { using (var sftp = new SftpClient(host, userName, password)) { sftp.OperationTimeout = new TimeSpan(0, 0, seconds: 40); sftp.Connect(); UploadFileWithOpenConnection(localFileToUpload, targetFile, sftp); sftp.Disconnect(); } }