Home Forums .NET libraries Xceed SFTP/FTP for .NET Zero Byte File When Uploading

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21484 |

    I have a program that is uploading files to be processed by a service.  The service watches the target folder and process each file it finds and then moves the file with a unique timestamp to an archive folder.

    What I see when my program sends its file is the server grabs the file right away, BEFORE bytes have been sent, then grabs the file a second time AFTER bytes have been sent.

    It would appear that SFtpConnection is creating and sending the file in two steps.  Or, perhaps I am using the library incorrectly.  🙂  Does anyone see a problem with how I am using the library?

    var host = “…”;

    var port = “…”;

    var sshKeyFile = “…”;

    var stream = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(sshKeyFile));

    var sshKey = new PuTTYPrivateKeyFile(stream);

    var file = “…”;

    var targetFolder = “…”;

    var sshClient = new SSHClient();

    sshClient.Connect(host, port);

    sshClient.Authenticate(username, sshKey);

    using (SFtpConnection sftp = new SFtpConnection(sshClient))

    {

    var filename = System.IO.Path.GetFileName(file);

    var localFolder = new DiskFolder(System.IO.Path.GetDirectoryName(file));

    var sourceFile = localFolder.GetFile(filename);

    var remoteFolder = new SFtpFolder(sftp, targetFolder);

    sourceFile.CopyTo(remoteFolder, true);

    }

     

    sshClient.Disconnect();

     

    Applies to Xceed SFTP for .NET. Imported from legacy forums. Posted by Aaron (had 662 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Aaron,

    You are correct. The library uploads a non-existing file in two steps.

    The lead developer has prepared a new build of the component where this behavior has been changed. A file that does not exist remotely is now created and opened for writing in one remote operation.

    This should fix your issue.

    You can download the build here:
    http://xceed.com/CS/forums/thread/32885.aspx

     

    Applies to Xceed SFTP for .NET. Imported from legacy forums. Posted by Diane [Xceed] (had 889 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.