public bool SaveImageToFTPServer(ImageSource imageSource, string imageLocationMemory, string imageLocationDisk) { BitmapEncoder encoder = new TiffBitmapEncoder(); byte[] biteArray = ImageSourceToBytes(encoder, imageSource); // Function returns byte[] csv file using (var client = new Renci.SshNet.SftpClient(Host, Port, Username, Password)) { client.Connect(); if (client.IsConnected) { client.ChangeDirectory(SFTPWorkingDirectory); using (var ms = new MemoryStream(biteArray)) { client.BufferSize = (uint)ms.Length; // bypass Payload error large files client.UploadFile(ms, imageLocationDisk); // imageLocationDisk == openFileDialog.FileName client.RenameFile(client.WorkingDirectory + "/" + imageLocationDisk, client.WorkingDirectory + "/" + imageLocationMemory); return(true); } } else { OutputMessage = "Couldn't connect to SFTP server."; return(false); } } }
public override bool RenameFile(string remotePath, string remoteNewPath) { _client.RenameFile(remotePath, remoteNewPath); return(true); }