I can't seem to get the Append flag to work when uploading a byte array. I'm making the call:-
ftpConnection.UploadByteArray(byteArray, remoteFile, true);
...and it's just overwriting the existing text in the file.
Here's the code from a sample console app I knocked up to demonstrate the problem (IP address, username etc changed out for dummy values):-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnterpriseDT.Net.Ftp;
using EnterpriseDT.Net.Ftp.Ssh;
namespace TestSFTP
{
class Program
{
static void Main(string[] args)
{
string remoteFile = "/data/ftb/RDFTransfer/TestFile.txt";
SecureFTPConnection ftpConnection = new SecureFTPConnection();
ftpConnection.Protocol = FileTransferProtocol.SFTP;
ftpConnection.ServerValidation = SecureFTPServerValidationType.Automatic;
ftpConnection.KnownHosts.LoadKnownHosts(@"C:\KnownHosts\KnownHosts");
ftpConnection.ServerAddress = "ANIPAddress";
ftpConnection.ServerPort = 22;
ftpConnection.UserName = "AUser";
ftpConnection.Password = "APassword";
ftpConnection.ShowHiddenFiles = false;
ftpConnection.Connect();
string textToPush = "Hello World";
byte[] byteArray = Encoding.Default.GetBytes(textToPush);
ftpConnection.UploadByteArray(byteArray, remoteFile, true);
textToPush = "Goodbye Cruel World";
byteArray = Encoding.Default.GetBytes(textToPush);
ftpConnection.UploadByteArray(byteArray, remoteFile, true);
ftpConnection.Close();
}
}
}
That results in a text file containing the phrase "Goodbye Cruel World". Am I missing something?