Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
1.6k views
in .NET FTP by (160 points)
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?

3 Answers

0 votes
by (162k points)
You're right - there's a bug in the code. It's amazing this hasn't been discovered before - I suppose appending using this method is very rare.

We've made a fix - email support if you'd like to try a patched DLL. The official fix will be in the next release.
0 votes
by (160 points)
Just tried the fixed dll and it's working perfectly. Thank you for an amazingly quick turn around.
0 votes
by (162k points)
Thanks - the fix will be in 8.6.5 when it comes out in due course.

Categories

...